From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25380 invoked by alias); 2 Mar 2005 21:54:44 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 25352 invoked by uid 48); 2 Mar 2005 21:54:41 -0000 Date: Wed, 02 Mar 2005 21:54:00 -0000 Message-ID: <20050302215441.25351.qmail@sourceware.org> From: "bangerth at dealii dot org" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20050215012640.19968.reichelt@gcc.gnu.org> References: <20050215012640.19968.reichelt@gcc.gnu.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/19968] [3.3/3.4/4.0/4.1 Regression] Warning omitted for non-derived classes X-Bugzilla-Reason: CC X-SW-Source: 2005-03/txt/msg00299.txt.bz2 List-Id: ------- Additional Comments From bangerth at dealii dot org 2005-03-02 21:54 ------- Correct. The class without inheritance doesn't need a constructor since objects of this type can be initialized using a brace-enclosed list. The class with inheritance is not POD, so it can't be initialized that way and needs a constructor. This should demonstrate this: ----------------- struct B {}; struct A1 : B { const int i; }; struct A2 { const int i; }; A1 a1 = { 1 }; // not ok A2 a2 = { 1 }; // ok ----------------- g/x> /home/bangerth/bin/gcc-3.4.4-pre/bin/c++ -W -Wall -ansi -pedantic -c x.cc x.cc:3: warning: non-static const member `const int A1::i' in class without a constructor x.cc:6: error: `a1' must be initialized by constructor, not by `{...}' This is therefore not a bug but correct behavior. W. -- What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19968