This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/63497] std::regex can't handle [^class] correctly and cause runtime crash
- From: "timshen at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 10 Oct 2014 11:03:33 +0000
- Subject: [Bug c++/63497] std::regex can't handle [^class] correctly and cause runtime crash
- Auto-submitted: auto-generated
- References: <bug-63497-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63497
--- Comment #2 from Tim Shen <timshen at gcc dot gnu.org> ---
Thanks for reporting :)
This bug is still in trunk, it just somehow can't trigger the segfault or wrong
output.
The line trunk/bits/regex_executor.tcc:297 :
if (__state._M_matches(*_M_current))
doesn't check if _M_current != _M_end.
One way is to create a helper function that may fail to (return a false as a
successfulness of dereference) dereference, but it's less efficient, unless the
compiler can do reasoning + unnecessary predication elimination. I'm not sure
about that.
If you are interested, take a look at _Executor::_M_word_boundary and try to
explode the first *_M_current (line 419 in trunk). My answer is:
regex_match("", regex("\\b"), regex_constants::match_not_eol);
For that case, can the compiler inline and eliminate unnecessary _M_current ==
_M_end, if we blindly check it (through some helper function) everywhere?
Or, as I prefer, I can do a file scope wise check for each direct or indirect
_M_current dereference.