[Bug c/67872] missing -Warray-bounds warning, bogus -Wmaybe-uninitialized
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67872 Martin Sebor changed: What|Removed |Added Status|ASSIGNED|NEW Assignee|msebor at gcc dot gnu.org |unassigned at gcc dot gnu.org --- Comment #5 from Martin Sebor --- I'm no longer working on this.
[Bug c/67872] missing -Warray-bounds warning, bogus -Wmaybe-uninitialized
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67872 Martin Sebor changed: What|Removed |Added CC||ch3root at openwall dot com --- Comment #4 from Martin Sebor --- *** Bug 71411 has been marked as a duplicate of this bug. ***
[Bug c/67872] missing -Warray-bounds warning, bogus -Wmaybe-uninitialized
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67872 Martin Sebor changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org
[Bug c/67872] missing -Warray-bounds warning, bogus -Wmaybe-uninitialized
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67872 Richard Biener changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2015-10-07 Ever confirmed|0 |1 --- Comment #3 from Richard Biener --- > gcc-5 -S t.c -O2 -Warray-bounds t.c: In function ‘foo’: t.c:7:14: warning: array subscript is above array bounds [-Warray-bounds] return a [4]; ^ same with current trunk. -O1 doesn't implement -Warray-bounds, it's part of value-range analysis. The uninit warning is a "feature", we optimize b[4] to "undefined" (and too early to catch -Warray-bounds). Confirmed for the fact that we miss a frontend based -Warray-bounds warning that can warn for those simple cases.
[Bug c/67872] missing -Warray-bounds warning, bogus -Wmaybe-uninitialized
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67872 --- Comment #2 from Martin Sebor --- (In reply to comment #1) Based on bug 41935 it looks like the offsetof warning is suppressed intentionally when the array is the last element of a struct.
[Bug c/67872] missing -Warray-bounds warning, bogus -Wmaybe-uninitialized
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67872 --- Comment #1 from Martin Sebor --- Looking for existing code in place to issue -Warray-bounds warnings I came across fold_offsetof_1 in c-family/c-common.c. The function is designed to warn for out of bounds indices in offsetof expressions but doesn't detect the following: struct A { int a[3]; } a; int foo (void) { return __builtin_offsetof (struct A, a[4]); } This (otherwise untested) patch fixes it and makes the function diagnose this case. (The comment about flexible array members above the block suggests that the patch might need tweaking to avoid false positives for such constructs.) --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -10623,7 +10623,8 @@ fold_offsetof_1 (tree expr) man's flexible array member with a very permissive definition thereof. */ if (TREE_CODE (v) == ARRAY_REF - || TREE_CODE (v) == COMPONENT_REF) + || TREE_CODE (v) == COMPONENT_REF + || TREE_CODE (v) == INDIRECT_REF) warning (OPT_Warray_bounds, "index %E denotes an offset " "greater than size of %qT",