https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90387
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2019-05-08
CC| |rguenth at gcc dot gnu.org
Component|c |tree-optimization
Blocks| |56456
Target Milestone|--- |9.2
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC indeed considers the __builtin_constant_p case here since it has not
finally committed to an answer at the point we warn for array-bound violations.
So it works as designed, even if maybe surprising.
We only commit to a final answer to __builtin_constant_p (false here)
"late" during optimization (first DOM pass which comes after the first VRP
pass). IMHO VRP itself could do this (IIRC I pasted a patch for this
in another bug).
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56456
[Bug 56456] [meta-bug] bogus/missing -Warray-bounds