From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23024 invoked by alias); 7 Nov 2011 23:04:02 -0000 Received: (qmail 23008 invoked by uid 22791); 7 Nov 2011 23:04:00 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-ww0-f51.google.com (HELO mail-ww0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 07 Nov 2011 23:03:47 +0000 Received: by wwf27 with SMTP id 27so6797001wwf.8 for ; Mon, 07 Nov 2011 15:03:46 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.221.163 with SMTP id r35mr624275wep.21.1320707025902; Mon, 07 Nov 2011 15:03:45 -0800 (PST) Received: by 10.216.63.83 with HTTP; Mon, 7 Nov 2011 15:03:45 -0800 (PST) In-Reply-To: References: Date: Mon, 07 Nov 2011 23:28:00 -0000 Message-ID: Subject: Re: [patch] c++/2972 warn when ctor-initializer leaves uninitialized data From: Jonathan Wakely To: Gabriel Dos Reis Cc: gcc-patches , Jason Merrill Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-11/txt/msg01098.txt.bz2 On 7 November 2011 22:38, Gabriel Dos Reis wrote: >> Unfortunately this doesn't work very well in C++11 mode, as defaulted >> constructors don't cause warnings when they should do e.g. >> >> struct C >> { >> =C2=A0int i; >> =C2=A0C() =3D default; >> }; >> >> This doesn't produce the same warning as C() {} even though that's >> what the defaulted constructor is equivalent to. > > so the defaulted constructor does not initialize C::i? [class.ctor] p6 A default constructor that is defaulted and not de=EF=AC=81ned as deleted is implicitly de=EF=AC=81ned when it is odr-used (3.2) to create an object of = its class type (1.8) or when it is explicitly defaulted after its =EF=AC=81rst declaration. The implicitly-de=EF=AC=81ned default constructor performs the set of initializations of the class that would be performed by a user-written default constructor for that class with no ctor-initializer (12.6.2) and an empty compound-statement.