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



             Bug #: 55128

           Summary: auto changes storage from .data to .rodata

    Classification: Unclassified

           Product: gcc

           Version: 4.7.2

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: ricil...@gmail.com





This is probably related to #49673 (as in, it's probably a case which was not

fixed by the fix to that bug.) I noticed it while mucking about with

compile-time array generation.



In this little extract, a and b are identical, except that b is automatically

typed. I can't see any reason why the type wouldn't be exactly the same as a's,

and the DWARF debugging information shows them as having the same type.

However, a ends up in .rodata (expected) and b in .data (unexpected). I have a

stronger expectation which is that both would be in the same section, but I'm

pretty sure that .rodata is correct.



code:



#include <array>



constexpr std::array<double, 1> makearray(double d) {

  return std::array<double, 1>{{d}};

}



extern const std::array<double, 1> a = makearray(1);

extern const auto b = makearray(1);



------------------------------------------------

General ASM with -O3 -S:



        .file   "auto1.cc"

        .globl  b

        .data

        .align 8

        .type   b, @object

        .size   b, 8

b:

        .long   0

        .long   1072693248

        .globl  a

        .section        .rodata

        .align 8

        .type   a, @object

        .size   a, 8

a:

        .long   0

        .long   1072693248

        .ident  "GCC: (Ubuntu/Linaro 4.7.2-4precise1) 4.7.2"

        .section        .note.GNU-stack,"",@progbits

Reply via email to