https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86519

--- Comment #10 from Martin Sebor <msebor at gcc dot gnu.org> ---
The code is undefined so the return value doesn't really matter but
conservatively, I think any non-zero value would work.  What to do is a
judgment call between letting the library call return some (possibly bogus and
unpredictable) value or crash, and folding the call into a predictable (but
possibly bogus) value and avoiding crashing.  If folding into a bogus value
despite the undefined behavior is a concern then folding the call to a
comparison of the minimum of sizeof(string-literal) and the memcmp size would
be another alternative to gain predictable results while avoiding reading past
the end.

Reply via email to