Bug 52719 - C++11 std::regex is broken compiling simple regular expressions
Summary: C++11 std::regex is broken compiling simple regular expressions
Status: RESOLVED DUPLICATE of bug 53631
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-26 08:28 UTC by Roger Leigh
Modified: 2012-06-11 08:36 UTC (History)
1 user (show)

See Also:
Host: x86_64-linux-gnu
Target: x86_64-linux-gnu
Build: x86_64-linux-gnu
Known to work:
Known to fail: 4.6.3, 4.7.0
Last reconfirmed:


Attachments
Working code using boost::regex (394 bytes, application/octet-stream)
2012-03-26 08:28 UTC, Roger Leigh
Details
Failing code using std::regex (394 bytes, application/octet-stream)
2012-03-26 08:29 UTC, Roger Leigh
Details
Preprocessed std::regex source (g++ -E) (194.27 KB, application/x-gzip)
2012-03-26 08:31 UTC, Roger Leigh
Details
Machine and compiler specs (2.22 KB, text/plain)
2012-03-26 08:31 UTC, Roger Leigh
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roger Leigh 2012-03-26 08:28:29 UTC
Created attachment 26991 [details]
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 ()
Comment 1 Roger Leigh 2012-03-26 08:29:23 UTC
Created attachment 26992 [details]
Failing code using std::regex
Comment 2 Roger Leigh 2012-03-26 08:31:09 UTC
Created attachment 26993 [details]
Preprocessed std::regex source (g++ -E)
Comment 3 Roger Leigh 2012-03-26 08:31:48 UTC
Created attachment 26994 [details]
Machine and compiler specs
Comment 4 Roger Leigh 2012-03-26 08:37:10 UTC
I left the priority as "normal", but if this is generally reproducible, and not a failure on my part, it would mean that std::regex is quite unusable in its current form.

Thanks,
Roger
Comment 5 Jonathan Wakely 2012-03-26 09:47:12 UTC
(In reply to comment #4)
> std::regex is quite unusable in its current form.

And documented as such in http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2011

The whole of Clause 28 is partially supported or not supported at all.
Comment 6 Jonathan Wakely 2012-06-11 08:36:34 UTC
.

*** This bug has been marked as a duplicate of bug 53631 ***