[Bug tree-optimization/86259] [8/9 Regression] min(4, strlen(s)) optimized to strlen(s) with -flto
joseph at codesourcery dot com
gcc-bugzilla@gcc.gnu.org
Fri Jun 22 16:38:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86259
--- Comment #13 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
Well, C90 TC1 adds (to the informative Annex listing undefined behavior)
the case of array subscripts being out of range even if they wouldn't be
simply based on the top-level object, such as a[1][7] given the
declaration int a[4][5]. And of course array references are defined in
terms of equivalent pointer arithmetic, so that's *(*(a+1) + 7). So
certainly for array objects, once you've got to a[1] or *(a+1) - as
opposed to &a[1] or &*(a+1) - you can't then get something from a[2] from
there. (But e.g. &a[1] + 1 is a perfectly valid way of writing &a[2].
And at least some of the examples here may be closer to that.)
More information about the Gcc-bugs
mailing list