http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52719
Bug #: 52719 Summary: C++11 std::regex is broken compiling simple regular expressions Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: rle...@debian.org Created attachment 26991 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26991 Working code using boost::regex This is reproducible with both GCC 4.6 and 4.7. Simple expressions such as "^[^:/,.][^:/,]*$" result in a regex_error exception being thrown. The exception what() method returns only "regex_error", rather than any informative message. The code previously used boost::regex, which worked perfectly well. The same regex also works with grep. I've attached: - working boost code - failing std::regex code - compiler info - g++ -E output The gdb backtrace is as follows: % gdb testr GNU gdb (GDB) 7.4-debian Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /home/rleigh/schroot/testr...(no debugging symbols found)...done. (gdb) catch throw Function "__cxa_throw" not defined. Catchpoint 1 (throw) (gdb) run Starting program: /home/rleigh/schroot/testr Catchpoint 1 (exception thrown), 0x000000319f862800 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (gdb) bt #0 0x000000319f862800 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #1 0x000000319f8b5a9d in std::__throw_regex_error(std::regex_constants::error_type) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #2 0x0000000000408bac in std::__regex::_Compiler<char const*, std::regex_traits<char> >::_M_bracket_expression() () #3 0x0000000000407db3 in std::__regex::_Compiler<char const*, std::regex_traits<char> >::_M_atom() () #4 0x0000000000406db5 in std::__regex::_Compiler<char const*, std::regex_traits<char> >::_M_term() () #5 0x0000000000405a28 in std::__regex::_Compiler<char const*, std::regex_traits<char> >::_M_alternative() () #6 0x0000000000405a72 in std::__regex::_Compiler<char const*, std::regex_traits<char> >::_M_alternative() () #7 0x0000000000404d38 in std::__regex::_Compiler<char const*, std::regex_traits<char> >::_M_disjunction() () #8 0x00000000004042ed in std::__regex::_Compiler<char const*, std::regex_traits<char> >::_Compiler(char const* const&, char const* const&, std::regex_traits<char>&, unsigned int) () #9 0x00000000004037e9 in std::shared_ptr<std::__regex::_Automaton> std::__regex::__compile<char const*, std::regex_traits<char> >(char const* const&, char const* const&, std::regex_traits<char>&, unsigned int) () #10 0x0000000000402e89 in std::basic_regex<char, std::regex_traits<char> >::basic_regex(char const*, unsigned int) () #11 0x0000000000401b16 in main ()