dimanche 21 décembre 2014

Clang 3.5.0 std::wregex compile error

Clang prints a strange error when I try to create a wide regex (std::wregex)



#include <regex>
#include <string>

int main() {
std::wregex myRegex( L"Hello Regex" );
return 0;
}


This code compiles fine without any errors or warnings with g++ (--std=c++11 -Wall), but clang++ (--std=c++11) generates this error:



In file included from test.cpp:1:
In file included from /usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/regex:60:
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.h:413:20: error: non-type template argument is not a constant expression
std::bitset<1 << (8 * sizeof(_CharT))>,
^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:398:53: note: in instantiation of template class
'std::__detail::_BracketMatcher<std::regex_traits<wchar_t>, false, false>' requested here
_BracketMatcher<_TraitsT, __icase, __collate> __matcher
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:316:25: note: in instantiation of function template specialization
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_insert_character_class_matcher<false, false>' requested here
__INSERT_REGEX_MATCHER(_M_insert_character_class_matcher);
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:288:8: note: expanded from macro '__INSERT_REGEX_MATCHER'
__func<false, false>(args);\
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:136:17: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_atom' requested here
if (this->_M_atom())
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:118:17: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_term' requested here
if (this->_M_term())
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:97:13: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_alternative' requested here
this->_M_alternative();
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:82:13: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_disjunction' requested here
this->_M_disjunction();
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.h:155:14: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_Compiler' requested here
return _Cmplr(__first, __last, __traits, __flags)._M_get_nfa();
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex.h:532:27: note: in instantiation of function template specialization
'std::__detail::__compile_nfa<std::regex_traits<wchar_t> >' requested here
_M_automaton(__detail::__compile_nfa(_M_original_str.c_str(),
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex.h:452:9: note: in instantiation of function template specialization 'std::basic_regex<wchar_t,
std::regex_traits<wchar_t> >::basic_regex<const wchar_t *>' requested here
: basic_regex(__p, __p + _Rx_traits::length(__p), __f)
^
test.cpp:5:17: note: in instantiation of member function 'std::basic_regex<wchar_t, std::regex_traits<wchar_t> >::basic_regex' requested here
std::wregex myRegex( L"Hello Regex" );
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.h:413:22: note: shift count 32 >= width of type 'int' (32 bits)
std::bitset<1 << (8 * sizeof(_CharT))>,
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.h:413:20: error: non-type template argument is not a constant expression
std::bitset<1 << (8 * sizeof(_CharT))>,
^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:398:53: note: in instantiation of template class
'std::__detail::_BracketMatcher<std::regex_traits<wchar_t>, false, true>' requested here
_BracketMatcher<_TraitsT, __icase, __collate> __matcher
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:316:25: note: in instantiation of function template specialization
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_insert_character_class_matcher<false, true>' requested here
__INSERT_REGEX_MATCHER(_M_insert_character_class_matcher);
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:290:8: note: expanded from macro '__INSERT_REGEX_MATCHER'
__func<false, true>(args);\
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:136:17: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_atom' requested here
if (this->_M_atom())
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:118:17: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_term' requested here
if (this->_M_term())
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:97:13: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_alternative' requested here
this->_M_alternative();
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:82:13: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_disjunction' requested here
this->_M_disjunction();
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.h:155:14: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_Compiler' requested here
return _Cmplr(__first, __last, __traits, __flags)._M_get_nfa();
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex.h:532:27: note: in instantiation of function template specialization
'std::__detail::__compile_nfa<std::regex_traits<wchar_t> >' requested here
_M_automaton(__detail::__compile_nfa(_M_original_str.c_str(),
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex.h:452:9: note: in instantiation of function template specialization 'std::basic_regex<wchar_t,
std::regex_traits<wchar_t> >::basic_regex<const wchar_t *>' requested here
: basic_regex(__p, __p + _Rx_traits::length(__p), __f)
^
test.cpp:5:17: note: in instantiation of member function 'std::basic_regex<wchar_t, std::regex_traits<wchar_t> >::basic_regex' requested here
std::wregex myRegex( L"Hello Regex" );
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.h:413:22: note: shift count 32 >= width of type 'int' (32 bits)
std::bitset<1 << (8 * sizeof(_CharT))>,
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.h:413:20: error: non-type template argument is not a constant expression
std::bitset<1 << (8 * sizeof(_CharT))>,
^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:398:53: note: in instantiation of template class
'std::__detail::_BracketMatcher<std::regex_traits<wchar_t>, true, false>' requested here
_BracketMatcher<_TraitsT, __icase, __collate> __matcher
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:316:25: note: in instantiation of function template specialization
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_insert_character_class_matcher<true, false>' requested here
__INSERT_REGEX_MATCHER(_M_insert_character_class_matcher);
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:293:8: note: expanded from macro '__INSERT_REGEX_MATCHER'
__func<true, false>(args);\
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:136:17: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_atom' requested here
if (this->_M_atom())
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:118:17: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_term' requested here
if (this->_M_term())
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:97:13: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_alternative' requested here
this->_M_alternative();
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:82:13: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_disjunction' requested here
this->_M_disjunction();
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.h:155:14: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_Compiler' requested here
return _Cmplr(__first, __last, __traits, __flags)._M_get_nfa();
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex.h:532:27: note: in instantiation of function template specialization
'std::__detail::__compile_nfa<std::regex_traits<wchar_t> >' requested here
_M_automaton(__detail::__compile_nfa(_M_original_str.c_str(),
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex.h:452:9: note: in instantiation of function template specialization 'std::basic_regex<wchar_t,
std::regex_traits<wchar_t> >::basic_regex<const wchar_t *>' requested here
: basic_regex(__p, __p + _Rx_traits::length(__p), __f)
^
test.cpp:5:17: note: in instantiation of member function 'std::basic_regex<wchar_t, std::regex_traits<wchar_t> >::basic_regex' requested here
std::wregex myRegex( L"Hello Regex" );
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.h:413:22: note: shift count 32 >= width of type 'int' (32 bits)
std::bitset<1 << (8 * sizeof(_CharT))>,
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.h:413:20: error: non-type template argument is not a constant expression
std::bitset<1 << (8 * sizeof(_CharT))>,
^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:398:53: note: in instantiation of template class
'std::__detail::_BracketMatcher<std::regex_traits<wchar_t>, true, true>' requested here
_BracketMatcher<_TraitsT, __icase, __collate> __matcher
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:316:25: note: in instantiation of function template specialization
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_insert_character_class_matcher<true, true>' requested here
__INSERT_REGEX_MATCHER(_M_insert_character_class_matcher);
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:295:8: note: expanded from macro '__INSERT_REGEX_MATCHER'
__func<true, true>(args);\
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:136:17: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_atom' requested here
if (this->_M_atom())
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:118:17: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_term' requested here
if (this->_M_term())
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:97:13: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_alternative' requested here
this->_M_alternative();
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.tcc:82:13: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_M_disjunction' requested here
this->_M_disjunction();
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.h:155:14: note: in instantiation of member function
'std::__detail::_Compiler<std::regex_traits<wchar_t> >::_Compiler' requested here
return _Cmplr(__first, __last, __traits, __flags)._M_get_nfa();
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex.h:532:27: note: in instantiation of function template specialization
'std::__detail::__compile_nfa<std::regex_traits<wchar_t> >' requested here
_M_automaton(__detail::__compile_nfa(_M_original_str.c_str(),
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex.h:452:9: note: in instantiation of function template specialization 'std::basic_regex<wchar_t,
std::regex_traits<wchar_t> >::basic_regex<const wchar_t *>' requested here
: basic_regex(__p, __p + _Rx_traits::length(__p), __f)
^
test.cpp:5:17: note: in instantiation of member function 'std::basic_regex<wchar_t, std::regex_traits<wchar_t> >::basic_regex' requested here
std::wregex myRegex( L"Hello Regex" );
^
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/regex_compiler.h:413:22: note: shift count 32 >= width of type 'int' (32 bits)
std::bitset<1 << (8 * sizeof(_CharT))>,
^
4 errors generated.


GCC Version: 4.9.2


Clang:



clang version 3.5.0 (tags/RELEASE_350/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix


Is this a clang bug or does clang need some additional headers? The normal std::regex works with both gcc and clang.


Aucun commentaire:

Enregistrer un commentaire