public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/37303]  New: const compound initializers in structs are written to .data instead of .rodata
@ 2008-08-31 20:47 anders at kaseorg dot com
  2008-09-02 20:58 ` [Bug c/37303] " pinskia at gcc dot gnu dot org
  2008-10-01 17:27 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 8+ messages in thread
From: anders at kaseorg dot com @ 2008-08-31 20:47 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1229 bytes --]

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-09-26 20:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-37303-4@http.gcc.gnu.org/bugzilla/>
2012-02-28  2:59 ` [Bug c/37303] const compound initializers in structs are written to .data instead of .rodata paracelsus at gmail dot com
2012-05-01 20:08 ` ian at airs dot com
2012-05-01 21:26 ` ian at airs dot com
2012-05-01 21:26 ` ian at gcc dot gnu.org
2012-05-06  4:02 ` pinskia at gcc dot gnu.org
2012-09-26 20:33 ` sje at gcc dot gnu.org
2008-08-31 20:47 [Bug c/37303] New: " anders at kaseorg dot com
2008-09-02 20:58 ` [Bug c/37303] " pinskia at gcc dot gnu dot org
2008-10-01 17:27 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).