https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109071
--- Comment #8 from Kees Cook <kees at outflux dot net> --- The warning is about: val = &sg->vals[index]; poc.c:20:20: warning: array subscript 4 is above array bounds of 'int[4]' [-Warray-bounds=] 20 | val = &sg->vals[index]; | ~~~~~~~~^~~~~~~ which happens before the warn(). And if the check is moved out of the "assign()" function, the warning goes away: val = &sg->vals[index]; if (index >= MAX_ENTRIES) warn(); assign(0, ptr, index); assign(*val, ptr, index); Normally -Warray-bounds doesn't warn when a value is totally unknown (i.e. "index" here can be [-INT_MAX,INT_MAX]). Why does the warning change when the MAX_ENTRIES test is moved inside assign()?