[Bug tree-optimization/86532] [9 Regression] Wrong code due to a wrong strlen folding starting with r262522
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jul 17 15:44:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86532
--- Comment #13 from Martin Sebor <msebor at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #9)
>
> I bet Martin would argue it's invalid ...
That's right, the example in comment 8 is undefined because strlen() requires a
nul-terminated string argument and a[0] in the call strlen(a[0]) is not such a
string. It's not valid for strlen() to access one subobject when passed a
pointer to another, even if the two are adjacent in memory. This applies
equally to struct members as well as multidimensional arrays.
More information about the Gcc-bugs
mailing list