This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/63497] std::regex can't handle [^class] correctly and cause runtime crash


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]