[Bug tree-optimization/86259] [8/9 Regression] min(4, strlen(s)) optimized to strlen(s) with -flto

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jun 21 14:38:00 GMT 2018


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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #8 from Martin Sebor <msebor at gcc dot gnu.org> ---
The code in comment #0 is undefined.  It's not valid to advance a pointer to A
to point to B and dereference the pointer.  It doesn't matter if the pointer
points to the outermost object or to one of its subobjects.  This is true for
hand-rolled loops as much as for functions like strlen that take strings as
arguments.  Likewise, the test case in comment #5 is undefined for the same
reason (a char array of size one can only hold the empty string).


More information about the Gcc-bugs mailing list