From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30824 invoked by alias); 3 Mar 2014 10:23:37 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 30765 invoked by uid 48); 3 Mar 2014 10:23:30 -0000 From: "wouter at voti dot nl" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/60399] New: constexpr ctor that does not init an attribute should be rejected but isn't Date: Mon, 03 Mar 2014 10:23:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.8.3 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: wouter at voti dot nl X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-03/txt/msg00171.txt.bz2 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