https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83428

            Bug ID: 83428
           Summary: Static initialization and struct with constexpr ctor
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wolfgang.roe...@gi-de.com
  Target Milestone: ---

Hi,

I would like to post a bug report for the GNU C/C++ compiler 6.0.0.
We use the compiler to generate code for a PowerPC processor.

Invokation line for the GNU C++ compiler:

ccppc -c -x c++ -std=gnu++14 -Wall -Werror -g -mcpu=e6500 -m32
      -maltivec -mvrsave -ftls-model=local-exec -msdata=sysv
      -fno-common -fno-openmp -mbig -mmultiple -mno-string -misel
      -mstrict-align -fverbose-asm -G 8 -O3
      -I<some include paths>
      -D<some #define's>
      X.CPP -oX.O


// file X.CPP

struct S1
{
    constexpr S1 ();

    int m_i;
};


struct alignas(64) S2
{
    constexpr S2 ()
    : m_tabS1()
    {}

    S1 m_tabS1[7];
};



S2 objX;


constexpr S1::S1 ()
: m_i(14)
{}


Inspection of the generated code shows that object objX is allocated in
section .bss which is zeroed before program start. The initialization is
later performed dynamically via a constructor function.
But according to the standard objX should initialized statically because
of its constexpr constructor (cf. 3.6.2/2).


With kind regards
W. Roehrl

Reply via email to