public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/61059] New: regex throws regex_error for valid extended regular expression
@ 2014-05-04 19:43 rleigh at debian dot org
  2014-05-04 21:16 ` [Bug libstdc++/61059] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: rleigh at debian dot org @ 2014-05-04 19:43 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61059

            Bug ID: 61059
           Summary: regex throws regex_error for valid extended regular
                    expression
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rleigh at debian dot org

Created attachment 32732
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32732&action=edit
Preprocessed source for testcase

Source:

--------[regextest.cpp]---------------------------------------------------------
#include <regex>

int main()
{
  std::regex description_keys("^description\\[.*\\]$", std::regex::extended);
}
--------------------------------------------------------------------------------

This RE has been used by code using boost::regex for around a decade.  The
failure is caused by escaping the "[" and "]" regex metacharacters with a
backslash "\" to match the literal character, so nothing too complex really. 
I'm fairly sure this is completely correct.  This compiles with GCC 4.9, but
fails at runtime in the regex constructor, shown below:


% gdb regextest 
GNU gdb (GDB) 7.6.2 (Debian 7.6.2-1)
This GDB was configured as "x86_64-linux-gnu".

(gdb) run
Starting program: /tmp/regextest 
warning: no loadable sections found in added symbol-file system-supplied DSO at
0x7ffff7ffd000
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
Traceback (most recent call last):
  File "/usr/lib/debug/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.20-gdb.py",
line 59, in <module>
    from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named libstdcxx.v6.printers
terminate called after throwing an instance of 'std::regex_error'
  what():  regex_error

Program received signal SIGABRT, Aborted.
0x00000033248353a9 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
56      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00000033248353a9 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00000033248384c8 in __GI_abort () at abort.c:89
#2  0x00007ffff7d1fd55 in __gnu_cxx::__verbose_terminate_handler () at
../../../../src/libstdc++-v3/libsupc++/vterminate.cc:95
#3  0x00007ffff7d1ddd6 in __cxxabiv1::__terminate (handler=<optimized out>) at
../../../../src/libstdc++-v3/libsupc++/eh_terminate.cc:47
#4  0x00007ffff7d1de21 in std::terminate () at
../../../../src/libstdc++-v3/libsupc++/eh_terminate.cc:57
#5  0x00007ffff7d1e038 in __cxxabiv1::__cxa_throw (obj=0x62b550,
tinfo=0x7ffff7fb13d0 <typeinfo for std::regex_error>, dest=
    0x7ffff7d74f70 <std::regex_error::~regex_error()>) at
../../../../src/libstdc++-v3/libsupc++/eh_throw.cc:87
#6  0x00007ffff7d74325 in std::__throw_regex_error
(__ecode=std::regex_constants::_S_error_escape) at
../../../../../src/libstdc++-v3/src/c++11/functexcept.cc:141
#7  0x0000000000404f56 in std::__detail::_Scanner<char>::_M_eat_escape_posix
(this=0x7fffffffe5b8) at /usr/include/c++/4.9/bits/regex_scanner.tcc:395
#8  0x0000000000405c59 in std::__detail::_Scanner<char>::_M_scan_normal
(this=0x7fffffffe5b8) at /usr/include/c++/4.9/bits/regex_scanner.tcc:110
#9  0x0000000000404fc3 in std::__detail::_Scanner<char>::_M_advance
(this=0x7fffffffe5b8) at /usr/include/c++/4.9/bits/regex_scanner.tcc:80
#10 0x000000000040426a in std::__detail::_Compiler<std::regex_traits<char>
>::_M_match_token (this=0x7fffffffe5a0,
token=std::__detail::_ScannerBase::_S_token_closure0)
    at /usr/include/c++/4.9/bits/regex_compiler.tcc:487
#11 0x00000000004080a5 in std::__detail::_Compiler<std::regex_traits<char>
>::_M_quantifier (this=0x7fffffffe5a0) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:187
#12 0x0000000000406b85 in std::__detail::_Compiler<std::regex_traits<char>
>::_M_term (this=0x7fffffffe5a0) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:138
#13 0x000000000040522e in std::__detail::_Compiler<std::regex_traits<char>
>::_M_alternative (this=0x7fffffffe5a0) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:118
#14 0x0000000000405251 in std::__detail::_Compiler<std::regex_traits<char>
>::_M_alternative (this=0x7fffffffe5a0) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:121
#15 0x0000000000405251 in std::__detail::_Compiler<std::regex_traits<char>
>::_M_alternative (this=0x7fffffffe5a0) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:121
#16 0x0000000000405251 in std::__detail::_Compiler<std::regex_traits<char>
>::_M_alternative (this=0x7fffffffe5a0) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:121
#17 0x0000000000405251 in std::__detail::_Compiler<std::regex_traits<char>
>::_M_alternative (this=0x7fffffffe5a0) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:121
#18 0x0000000000405251 in std::__detail::_Compiler<std::regex_traits<char>
>::_M_alternative (this=0x7fffffffe5a0) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:121
#19 0x0000000000405251 in std::__detail::_Compiler<std::regex_traits<char>
>::_M_alternative (this=0x7fffffffe5a0) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:121
#20 0x0000000000405251 in std::__detail::_Compiler<std::regex_traits<char>
>::_M_alternative (this=0x7fffffffe5a0) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:121
#21 0x0000000000405251 in std::__detail::_Compiler<std::regex_traits<char>
>::_M_alternative (this=0x7fffffffe5a0) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:121
#22 0x0000000000405251 in std::__detail::_Compiler<std::regex_traits<char>
>::_M_alternative (this=0x7fffffffe5a0) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:121
#23 0x0000000000405251 in std::__detail::_Compiler<std::regex_traits<char>
>::_M_alternative (this=0x7fffffffe5a0) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:121
#24 0x0000000000405251 in std::__detail::_Compiler<std::regex_traits<char>
>::_M_alternative (this=0x7fffffffe5a0) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:121
#25 0x0000000000405251 in std::__detail::_Compiler<std::regex_traits<char>
>::_M_alternative (this=0x7fffffffe5a0) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:121
#26 0x0000000000405251 in std::__detail::_Compiler<std::regex_traits<char>
>::_M_alternative (this=0x7fffffffe5a0) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:121
#27 0x0000000000404122 in std::__detail::_Compiler<std::regex_traits<char>
>::_M_disjunction (this=0x7fffffffe5a0) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:97
#28 0x000000000040391c in std::__detail::_Compiler<std::regex_traits<char>
>::_Compiler (this=0x7fffffffe5a0, __b=0x62b028 "^description\\[.*\\]$",
__e=0x62b03b "", 
    __traits=..., __flags=std::regex_constants::extended) at
/usr/include/c++/4.9/bits/regex_compiler.tcc:82
#29 0x00000000004034e4 in std::__detail::__compile_nfa<std::regex_traits<char>
> (__first=0x62b028 "^description\\[.*\\]$", __last=0x62b03b "", __traits=..., 
    __flags=std::regex_constants::extended) at
/usr/include/c++/4.9/bits/regex_compiler.h:155
#30 0x0000000000403257 in std::basic_regex<char, std::regex_traits<char>
>::basic_regex<char const*> (this=0x7fffffffe800, __first=0x41bc6e
"^description\\[.*\\]$", 
    __last=0x41bc81 "", __f=std::regex_constants::extended) at
/usr/include/c++/4.9/bits/regex.h:528
#31 0x0000000000402fdf in std::basic_regex<char, std::regex_traits<char>
>::basic_regex (this=0x7fffffffe800, __p=0x41bc6e "^description\\[.*\\]$", 
    __f=std::regex_constants::extended) at
/usr/include/c++/4.9/bits/regex.h:452
#32 0x0000000000402588 in main () at regextest.cpp:5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libstdc++/61059] regex throws regex_error for valid extended regular expression
  2014-05-04 19:43 [Bug libstdc++/61059] New: regex throws regex_error for valid extended regular expression rleigh at debian dot org
@ 2014-05-04 21:16 ` redi at gcc dot gnu.org
  2014-05-04 21:17 ` redi at gcc dot gnu.org
  2014-05-05 18:27 ` rleigh at debian dot org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2014-05-04 21:16 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61059

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
      Known to work|                            |4.10.0
         Resolution|---                         |INVALID
   Target Milestone|---                         |4.9.1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced:

#include <regex>

int main()
{
  std::regex description_keys("\\]", std::regex::extended);
}

POSIX says this is undefined:
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04_02

The closing brace is not a POSIX ERE special character so should not be
escaped.

As a GNU extension we accept it with -std=gnu++11


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libstdc++/61059] regex throws regex_error for valid extended regular expression
  2014-05-04 19:43 [Bug libstdc++/61059] New: regex throws regex_error for valid extended regular expression rleigh at debian dot org
  2014-05-04 21:16 ` [Bug libstdc++/61059] " redi at gcc dot gnu.org
@ 2014-05-04 21:17 ` redi at gcc dot gnu.org
  2014-05-05 18:27 ` rleigh at debian dot org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2014-05-04 21:17 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61059

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|4.10.0                      |
   Target Milestone|4.9.1                       |---

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(Unsetting fields I accidentally filled in on the wrong browser tab)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libstdc++/61059] regex throws regex_error for valid extended regular expression
  2014-05-04 19:43 [Bug libstdc++/61059] New: regex throws regex_error for valid extended regular expression rleigh at debian dot org
  2014-05-04 21:16 ` [Bug libstdc++/61059] " redi at gcc dot gnu.org
  2014-05-04 21:17 ` redi at gcc dot gnu.org
@ 2014-05-05 18:27 ` rleigh at debian dot org
  2 siblings, 0 replies; 4+ messages in thread
From: rleigh at debian dot org @ 2014-05-05 18:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61059

--- Comment #3 from Roger Leigh <rleigh at debian dot org> ---
Thanks for the clarification.

Just for reference for anyone else running into this behaviour:

clang++3.3: compiles and runs
VS2012: compiles and throws regex_error
VS2013: compiles and throws regex_error


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-05-05 18:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-04 19:43 [Bug libstdc++/61059] New: regex throws regex_error for valid extended regular expression rleigh at debian dot org
2014-05-04 21:16 ` [Bug libstdc++/61059] " redi at gcc dot gnu.org
2014-05-04 21:17 ` redi at gcc dot gnu.org
2014-05-05 18:27 ` rleigh at debian dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).