http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60399
Bug ID: 60399 Summary: constexpr ctor that does not init an attribute should be rejected but isn't Product: gcc Version: 4.8.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: wouter at voti dot nl Created attachment 32250 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32250&action=edit cpp stanalone main file that shows the problem AFAIK A constexpr constructor that does not initialize all attributes should be rejected. In the attached code, which is accepted by the compiler, such a constructor is invoked in the initialization of a static class attribute. To my surprise the compiler generates an init_array entry for this (which is what triggered me to dig into this, I work with a linkerscript that does not allow any int_array entries). The generated entry is basically empty, just static done = false; if( ! done ){ done = true; } When I make the constexpr constructor initialize the attribute the init_array entry is gone. I use GCC for ARM, 4.8.3 "C:/Program Files (x86)/GNU Tools ARM Embedded/4.8 2013q4/bin/arm-none-eabi-g++" -nostartfiles -mcpu=cortex-m0 -mthumb -fomit-frame-pointer -march=armv6-m -Wall -Werror -Wno-unused-local-typedefs -Wno-maybe-uninitialized -fdata-sections -ffunction-sections -Os -fno-rtti -fno-exceptions -fno-threadsafe-statics -fno-use-cxa-get-exception-ptr -std=c++11 -c -o main.o main.cpp