http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60121
--- Comment #3 from Zhendong Su <su at cs dot ucdavis.edu> --- (In reply to Andrew Pinski from comment #2) > I think this is expected. out of bounds warnings come not from the front-end > but the middle-end and are designed not to warn about in dead code. This > code is dead as a != 0 is always false. Andrew, it's actually the complete opposite with this testcase. At -O0 and -O1, gcc unlikely knows that the out-of-bound array access is dead, so the warning should be issued, but it's not. On the other hand, at -Os and above, gcc likely knows that the out-of-bound array access is dead, but it warns.