Bug in libc++

Hello,
I am newcomer, and I don't where I should post it.
I find bug in libc++ in regex. This is my code sample:

#include <iostream>
#include <regex>
#include <string>

int main() {

     std::string HW("HelloWorld");
     std::regex RE("[^\\W]");

     if (std::regex_search(HW, RE))
         std::cout << "regexp is OK";
     else
         std::cout << "regexp is broken";

     std::cout << std::endl;
     return 0;
}

This is my command for compilation:
clang++ -std=c++11 -stdlib=libc++ main.cpp

And I get:
regexp is broken

But, if I use libstdc++ :

clang++ -std=c++11 -stdlib=libstdc++ main.cpp

It's ok:
regexp is OK

I get bug only for regexp [^\\W] and for combinations with it.

I use libc++dev form ubuntu version: 3.9.1-2

Hi Aleksandr,

I think libc++ is correct. C++11 defines \W as being equivalent to
[^_[:alnum:]], which means your regex is "[^[^_[:alnum:]]]". I believe
that'll be parsed as "some weird character followed by ]]".

Sorry, just one ] at the end since there is still a valid [:alnum:] in there.

Tim.

This bug seems to hint that libstdc++ had a bug in how it treated this and claims that ECMAScript sayd that \W should be equivalent to [\W] – https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61227

Hi, Tim.

This is wrong. [\W] and [^\W] should be valid expressions. User of libc++ doesn't how it implemented, "\W" will be replaced [^_[:alnum:]] or vice versa. It should works in any way. Regex [^\W] work in the most standart tools. I didn't read standard of ECMAScript, but I am sure, that [^\W] will be valid according to it. Maybe I an wrong, so say me, that ECMAScript doesn't allow this. But explanation, that you give, say me, that this is problem only implementation libc++. Maybe is should be implemented in another way, not just define \W as ^_[:alnum:].