Summary: | Array-boundary offending code is silently discarded without warnings | ||
---|---|---|---|
Product: | gcc | Reporter: | Ilia Kolominsky <ilia.kolominsky> |
Component: | tree-optimization | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | NEW --- | ||
Severity: | enhancement | CC: | manu |
Priority: | P3 | Keywords: | diagnostic |
Version: | 4.8.2 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | 5.3.0 | Last reconfirmed: | 2016-01-13 00:00:00 |
Description
Ilia Kolominsky
2016-01-12 16:11:24 UTC
No warning: -O3 -Waggressive-loop-optimizations -Warray-bounds -Wextra -Wall -Wstrict-aliasing=3 -Wstrict-overflow=5 Confirmed as diagnostic enhancement request. I see the same behavior on incorrect code (off-by-one bug accessing beyond the array, in my case with a negative index) on Linux kernel code: The following snippet produces a warning with all versions up to 4.7, but not with 4.8 or later (latest tried: gcc-8.0.0): 8<---- #define MEDIA_BUS_FMT_YUYV8_2X8 0x2008 #define MEDIA_BUS_FMT_YVYU8_2X8 0x2009 #define MEDIA_BUS_FMT_UYVY8_2X8 0x2006 #define MEDIA_BUS_FMT_VYUY8_2X8 0x2007 static const unsigned int camif_mbus_formats[4] = { MEDIA_BUS_FMT_YUYV8_2X8, MEDIA_BUS_FMT_YVYU8_2X8, MEDIA_BUS_FMT_UYVY8_2X8, MEDIA_BUS_FMT_VYUY8_2X8, }; int __camif_subdev_try_format(unsigned int code) { int i = sizeof(camif_mbus_formats) / sizeof(camif_mbus_formats[0]); while (i-- >= 0) if (camif_mbus_formats[i] == code) break; return i; } |