------- Comment #13 from rguenth at gcc dot gnu dot org 2010-03-06 14:27
-------
Err - it's just because the code is broken:
tree low_bound, up_bound = array_ref_up_bound (ref);
low_sub = up_sub = TREE_OPERAND (ref, 1);
if (!up_bound || TREE_NO_WARNING (ref)
|| TREE_CODE (up_bound) != INTEGER_CST
/* Can not check flexible arrays. */
|| (TYPE_SIZE (TREE_TYPE (ref)) == NULL_TREE
&& TYPE_DOMAIN (TREE_TYPE (ref)) != NULL_TREE
&& TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (ref))) == NULL_TREE)
well - this checks TYPE_SIZE/DOMAIN on the element type ...
and the struct hack check is too strict:
/* Accesses after the end of arrays of size 0 (gcc
extension) and 1 are likely intentional ("struct
hack"). */
|| compare_tree_int (up_bound, 1) <= 0)
Replacing that with a more proper (but still too strict) check like
/* Accesses after the end of arrays at the end of structures
are likely intentional ("struct hack"). */
if (TREE_CODE (TREE_OPERAND (ref, 0)) == COMPONENT_REF
&& !TREE_CHAIN (TREE_OPERAND (TREE_OPERAND (ref, 0), 1)))
return;
gets you
t.C: In function 'int main()':
t.C:27:45: warning: array subscript is above array bounds
it doesn't print that this is from an inlined constructor though.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot
|dot org |org
Severity|normal |enhancement
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-03-06 14:27:49
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43270