[Bug c/88867] New: -Waggressive-loop-optimizations doesn't warn when -faggressive-loop-optimizations is in play
levon at movementarian dot org
gcc-bugzilla@gcc.gnu.org
Tue Jan 15 18:11:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88867
Bug ID: 88867
Summary: -Waggressive-loop-optimizations doesn't warn when
-faggressive-loop-optimizations is in play
Product: gcc
Version: 8.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: levon at movementarian dot org
Target Milestone: ---
Given how dangerous -faggressive-loop-optimizations has been proven to be, it's
unfortunate that -Waggressive-loop-optimizations is non-functional in even
simple cases. For example this test case:
#define NULL ((void *)0)
static char *arr[2] = { "nasal", "demons" };
long
func()
{
int i;
for (i = 0; i <= 2; i++) {
if (arr[i] == NULL && i == 0)
return (0xbad);
}
return (0xfad);
}
Is optimized to "return 0xbad" with -faggressive-loop-optimizations, but it is
not possible to get GCC to warn about this. -Waggressive-loop-optimizations
should warn every single time it relies on out-of-bounds behaviour like this.
Otherwise, such code becomes impossible to find and fix.
Same with trunk gcc on godbolt:
https://godbolt.org/z/MN1beq
More information about the Gcc-bugs
mailing list