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; 3+ 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] 3+ messages in thread

* [Bug c/37303] const compound initializers in structs are written to .data instead of .rodata
  2008-08-31 20:47 [Bug c/37303] New: const compound initializers in structs are written to .data instead of .rodata anders at kaseorg dot com
@ 2008-09-02 20:58 ` pinskia at gcc dot gnu dot org
  2008-10-01 17:27 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-09-02 20:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-09-02 20:57 -------
Confirmed, not a regression as far as I can tell.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |missed-optimization
      Known to fail|                            |3.3.3 4.0.1 4.1.1 4.4.0
   Last reconfirmed|0000-00-00 00:00:00         |2008-09-02 20:57:27
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37303


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

* [Bug c/37303] const compound initializers in structs are written to .data instead of .rodata
  2008-08-31 20:47 [Bug c/37303] New: const compound initializers in structs are written to .data instead of .rodata 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
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-10-01 17:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2008-10-01 17:25 -------
>From C99 6.5.2.5/8:

"String literals, and compound literals with const-qualified types, need not
designate distinct objects"


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37303


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

end of thread, other threads:[~2008-10-01 17:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-31 20:47 [Bug c/37303] New: const compound initializers in structs are written to .data instead of .rodata 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).