This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/37303] New: const compound initializers in structs are written to .data instead of .rodata
- From: "anders at kaseorg dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 Aug 2008 20:45:54 -0000
- Subject: [Bug c/37303] New: const compound initializers in structs are written to .data instead of .rodata
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
GCC generates identical code for the following two structures:
const struct { const int *p; } foo = { (const int []) {1, 2, 3} };
const struct { int *p; } foo = { (int []) {1, 2, 3} };
In both cases, the struct is written to the .rodata section, but the array {1,
2, 3} is written to the .data section:
.section .rodata
.align 8
.type foo, @object
.size foo, 8
foo:
.quad __compound_literal.0
.data
.align 4
.type __compound_literal.0, @object
.size __compound_literal.0, 12
__compound_literal.0:
.long 1
.long 2
.long 3
For the first struct, where the array is const, it should also be written to
the .rodata section.
I?m using gcc 4.3.2-0ubuntu2 on Intrepid amd64.
--
Summary: const compound initializers in structs are written to
.data instead of .rodata
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: anders at kaseorg dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37303