[Bug c/86670] New: unsized static array var is removed but still accessed.
iains at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jul 25 09:34:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86670
Bug ID: 86670
Summary: unsized static array var is removed but still
accessed.
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: iains at gcc dot gnu.org
Target Milestone: ---
Created attachment 44436
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44436&action=edit
example code showing the issue
gcc-trunk-build$ ./gcc/xgcc -Bgcc ../static-var-removed-and-accessed.c -c
-save-temps -Wall -O0
<no diagnostic for O0..3 or Wextra>
Here we have
static int a[];
which is later assigned to.
===
we don't emit any storage for a, and it is silently changed to an undefined
external.
gcc-trunk-build$ nm static-var-removed-and-accessed.o
U a
00000000 T foo
gcc-trunk-build$ objdump -dr static-var-removed-and-accessed.o
<snip>
29: 8b 55 fc mov -0x4(%ebp),%edx
2c: 89 14 85 00 00 00 00 mov %edx,0x0(,%eax,4)
2f: R_386_32 a
33: 83 45 f8 01 addl $0x1,-0x8(%ebp)
37: 81 7d f8 ff 00 00 00 cmpl $0xff,-0x8(%ebp)
====
The code is wrong, of course, but we are neither diagnosing, nor producing
sensible output.
I noticed this because it fails at assembly time on m32 Darwin (where the
compiler has concluded that 'a' is TU-local, but not present).
More information about the Gcc-bugs
mailing list