[Bug tree-optimization/91457] FAIL: g++.dg/warn/Warray-bounds-4.C -std=gnu++98 (test for warnings, line 25)
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Aug 15 15:43:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91457
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2019-08-15
CC| |msebor at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed. Here's a slightly simplified/modified test case showing the
difference in output between an x86_64 native GCC and an hppa2.0w-hp-hpux11.11
cross. Here too compute_objsize fails because it doesn't handle the ARRAY_REF
argument in the assignment a.a[0] = 0.
$ (set -x && cat t.C && gcc -O2 -S -Wall -fdump-tree-dom3=/dev/stdout t.C &&
/build/hppa2.0w-hp-hpux11.11/gcc-svn/gcc/xgcc -B
/build/hppa2.0w-hp-hpux11.11/gcc-svn/gcc -O2 -S -Wall
-fdump-tree-dom3=/dev/stdout t.C)
+ cat t.C
struct A
{
char n, a[0];
A () { a[0] = 0; }
};
void f (struct A*);
void g (void)
{
struct A a;
f (&a);
}
+ /build/gcc-svn/gcc/xgcc -B /build/gcc-svn/gcc -O2 -S -Wall
-fdump-tree-dom3=/dev/stdout t.C
t.C: In function ‘void g()’:
t.C:5:13: warning: array subscript 0 is above array bounds of ‘char [0]’
[-Warray-bounds]
5 | A () { a[0] = 0; }
| ~~~^
;; Function g (_Z1gv, funcdef_no=3, decl_uid=2317, cgraph_uid=4,
symbol_order=3)
;; 1 loops found
;;
;; Loop 0
;; header 0, latch 1
;; depth 0, outer -1
;; nodes: 0 1 2
;; 2 succs { 1 }
g ()
{
struct A a;
<bb 2> [local count: 1073741824]:
a ={v} {CLOBBER};
a.a[0] = 0;
f (&a);
a ={v} {CLOBBER};
return;
}
+ /build/hppa2.0w-hp-hpux11.11/gcc-svn/gcc/xgcc -B
/build/hppa2.0w-hp-hpux11.11/gcc-svn/gcc -O2 -S -Wall
-fdump-tree-dom3=/dev/stdout t.C
;; Function g (_Z1gv, funcdef_no=3, decl_uid=1911, cgraph_uid=4,
symbol_order=3)
;; 1 loops found
;;
;; Loop 0
;; header 0, latch 1
;; depth 0, outer -1
;; nodes: 0 1 2
;; 2 succs { 1 }
g ()
{
struct A a;
<bb 2> [local count: 1073741824]:
MEM[(char *)&a + 1B] = 0;
f (&a);
a ={v} {CLOBBER};
return;
}
In constructor ‘A::A()’,
inlined from ‘void g()’ at t.C:12:12:
t.C:5:15: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
5 | A () { a[0] = 0; }
| ~~~~~^~~
More information about the Gcc-bugs
mailing list