https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118889
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think variables with 'static' linkage cannot be 'common'? That is, it works
with
__attribute__((common))
volatile int z;
and it's odd that we emit .comm with -fcommon for your testcase (I'd even call
that wrong and the use should be diagnosed?)
That said, your testcase, with -fcommon (no -fdata-sections) outputs
.file "t.c"
.text
.local z
.comm z,4,4
.globl main
.type main, @function
main:
...
for me on x86_64 but the assembler makes this into
[ 4] .bss NOBITS 0000000000000000 0000004c
0000000000000004 0000000000000000 WA 0 0 4
...
Symbol table '.symtab' contains 6 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FILE LOCAL DEFAULT ABS t.c
2: 0000000000000000 0 SECTION LOCAL DEFAULT 1 .text
3: 0000000000000000 0 SECTION LOCAL DEFAULT 4 .bss
4: 0000000000000000 4 OBJECT LOCAL DEFAULT 4 z
5: 0000000000000000 12 FUNC GLOBAL DEFAULT 1 main
as opposed to with 'static' dropped
Symbol table '.symtab' contains 5 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FILE LOCAL DEFAULT ABS t.c
2: 0000000000000000 0 SECTION LOCAL DEFAULT 1 .text
3: 0000000000000004 4 OBJECT GLOBAL DEFAULT COM z
4: 0000000000000000 12 FUNC GLOBAL DEFAULT 1 main