This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/21454] New: const array doesn't live in the rodata section in C++
- From: "kazu at cs dot umass dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 May 2005 16:06:40 -0000
- Subject: [Bug c++/21454] New: const array doesn't live in the rodata section in C++
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider:
static const int array[] = { 0, 1, 2, 3 };
int
foo (unsigned int i)
{
return array[i];
}
I get:
.file "test.cc"
.text
.align 2
.p2align 2,,3
.globl _Z3fooj
.type _Z3fooj, @function
_Z3fooj:
.LFB2:
movl 4(%esp), %eax
movl array(,%eax,4), %eax
ret
.LFE2:
.size _Z3fooj, .-_Z3fooj
.data
.align 4
.type array, @object
.size array, 16
array:
.long 0
.long 1
.long 2
.long 3
.ident "GCC: (GNU) 4.1.0 20050508 (experimental)"
.section .note.GNU-stack,"",@progbits
Note ".data". We could use ".rodata" for this array.
--
Summary: const array doesn't live in the rodata section in C++
Product: gcc
Version: unknown
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kazu at cs dot umass dot edu
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21454