Created attachment 36055 [details] regex.cc [forwarded from https://bugs.debian.org/778112] This regex is failing: std::regex("^[a-z0-9][a-z0-9-]*$", std::regex::extended); however this one works: std::regex("^[a-z0-9][-a-z0-9]*$", std::regex::extended); I'm unable to reproduce the claim in the original bug report with regex2.cc. $ cat run.sh g++-4.8 -static-libstdc++ -std=c++0x regex.cc && ./a.out g++-4.9 -static-libstdc++ -std=c++0x regex.cc && ./a.out g++-5 -static-libstdc++ -std=c++0x regex.cc && ./a.out /usr/lib/gcc-snapshot/bin/g++ -static-libstdc++ -std=c++0x regex.cc && ./a.out clang++-3.5 -stdlib=libc++ -std=c++0x regex.cc && ./a.out clang++-3.6 -stdlib=libc++ -std=c++0x regex.cc && ./a.out g++-4.8 -static-libstdc++ -std=c++0x regex2.cc && ./a.out g++-4.9 -static-libstdc++ -std=c++0x regex2.cc && ./a.out g++-5 -static-libstdc++ -std=c++0x regex2.cc && ./a.out /usr/lib/gcc-snapshot/bin/g++ -static-libstdc++ -std=c++0x regex2.cc && ./a.out clang++-3.5 -stdlib=libc++ -std=c++0x regex2.cc && ./a.out clang++-3.6 -stdlib=libc++ -std=c++0x regex2.cc && ./a.out + g++-4.8 -static-libstdc++ -std=c++0x regex.cc + ./a.out E0: regex_error a.out: regex.cc:24: int main(): Assertion `std::regex_match("test", debian_cron_namespace)' failed. Aborted (core dumped) + g++-4.9 -static-libstdc++ -std=c++0x regex.cc + ./a.out E1: regex_error + g++-5 -static-libstdc++ -std=c++0x regex.cc + ./a.out E1: regex_error + /usr/lib/gcc-snapshot/bin/g++ -static-libstdc++ -std=c++0x regex.cc + ./a.out E1: regex_error + clang++-3.5 -stdlib=libc++ -std=c++0x regex.cc + ./a.out + clang++-3.6 -stdlib=libc++ -std=c++0x regex.cc + ./a.out + g++-4.8 -static-libstdc++ -std=c++0x regex2.cc + ./a.out E0: regex_error E1: regex_error E2: regex_error + g++-4.9 -static-libstdc++ -std=c++0x regex2.cc + ./a.out + g++-5 -static-libstdc++ -std=c++0x regex2.cc + ./a.out + /usr/lib/gcc-snapshot/bin/g++ -static-libstdc++ -std=c++0x regex2.cc + ./a.out + clang++-3.5 -stdlib=libc++ -std=c++0x regex2.cc + ./a.out + clang++-3.6 -stdlib=libc++ -std=c++0x regex2.cc + ./a.out
Created attachment 36056 [details] regex2.cc
Note regex2.cc fails with 4.9.2 but not with 4.9.3 or 5.1, so this appear to have been fixed.
patch posted at https://gcc.gnu.org/ml/gcc-patches/2015-07/msg02177.html https://gcc.gnu.org/ml/libstdc++/2015-07/msg00068.html
Author: timshen Date: Wed Jul 29 03:45:35 2015 New Revision: 226336 URL: https://gcc.gnu.org/viewcvs?rev=226336&root=gcc&view=rev Log: PR libstdc++/67015 * include/bits/regex_compiler.h (_Compiler<>::_M_expression_term, _BracketMatcher<>::_M_add_collating_element): Change signature to make checking the and of bracket expression easier. * include/bits/regex_compiler.tcc (_Compiler<>::_M_expression_term): Treat '-' as a valid literal if it's at the end of bracket expression. * testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc: New testcases. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/bits/regex_compiler.h trunk/libstdc++-v3/include/bits/regex_compiler.tcc trunk/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc
Author: timshen Date: Wed Jul 29 04:30:25 2015 New Revision: 226337 URL: https://gcc.gnu.org/viewcvs?rev=226337&root=gcc&view=rev Log: Backport from mainline 2015-07-29 Tim Shen <timshen@google.com> PR libstdc++/67015 * include/bits/regex_compiler.h (_Compiler<>::_M_expression_term, _BracketMatcher<>::_M_add_collating_element): Change signature to make checking the and of bracket expression easier. * include/bits/regex_compiler.tcc (_Compiler<>::_M_expression_term): Treat '-' as a valid literal if it's at the end of bracket expression. * testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc: New testcases. Modified: branches/gcc-5-branch/libstdc++-v3/ChangeLog branches/gcc-5-branch/libstdc++-v3/include/bits/regex_compiler.h branches/gcc-5-branch/libstdc++-v3/include/bits/regex_compiler.tcc branches/gcc-5-branch/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc
Fixed in trunk and gcc5. Mark as fixed.
I think it would be a good idea to backport this fix to 4.9 as well, that version will be in use out in the wild for quite some time. I'm not hell-bent on having such a backport, I just think it would seem reasonable.
(In reply to Ville Voutilainen from comment #7) > I think it would be a good idea to backport this fix to 4.9 as well, that > version will be in use out in the wild for quite some time. I'm not hell-bent > on having such a backport, I just think it would seem reasonable. Well we've decided not to do so... https://gcc.gnu.org/ml/libstdc++/2015-07/msg00083.html But to be honest I have no idea of the user side. So I'll leave this to Jonathan. BTW, backporting takes trivial effort.
(In reply to Tim Shen from comment #8) > Well we've decided not to do so... > https://gcc.gnu.org/ml/libstdc++/2015-07/msg00083.html Yes, I read that, that's why I commented on this bug, I'd like to change Jonathan's mind about it. :)
Few more links to think about backporting to 4.9: https://bugs.gentoo.org/show_bug.cgi?id=555648 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=778112
OK, let's backport to 4.9 too.
Author: timshen Date: Wed Aug 5 04:39:23 2015 New Revision: 226607 URL: https://gcc.gnu.org/viewcvs?rev=226607&root=gcc&view=rev Log: Backported from mainline 2015-07-29 Tim Shen <timshen@google.com> PR libstdc++/67015 * include/bits/regex_compiler.h (_Compiler<>::_M_expression_term, _BracketMatcher<>::_M_add_collating_element): Change signature to make checking the and of bracket expression easier. * include/bits/regex_compiler.tcc (_Compiler<>::_M_expression_term): Treat '-' as a valid literal if it's at the end of bracket expression. * testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc: New testcases. Modified: branches/gcc-4_9-branch/libstdc++-v3/ChangeLog branches/gcc-4_9-branch/libstdc++-v3/include/bits/regex_compiler.h branches/gcc-4_9-branch/libstdc++-v3/include/bits/regex_compiler.tcc branches/gcc-4_9-branch/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc