From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16852 invoked by alias); 7 Dec 2006 17:51:47 -0000 Received: (qmail 16825 invoked by uid 48); 7 Dec 2006 17:51:37 -0000 Date: Thu, 07 Dec 2006 17:51:00 -0000 Subject: [Bug c++/30111] New: Value-initialization of POD base class doesn't initialize members X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "gcc-bugzilla at kayari dot org" 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 X-SW-Source: 2006-12/txt/msg00619.txt.bz2 #include int main() { struct pod { int i; }; struct inherit : pod { inherit() : pod() {} }; struct compose { compose() : p() {} pod p; }; inherit i; compose c; std::cout << i.i << std::endl; std::cout << c.p.i << std::endl; } In both cases the pod object is explicitly value-initialized, which according to 8.5para5 means that "every non-static data member ... is value-initialized" compose::pod::i is value-initialised, inherit::i is not. This can be seen from the values printed out for i.i and by using Purify. Same result with GCC 4.1.1, 3.4.3, 3.3.4 on Solaris 9, GCC 3.4.3 on AIX 5/3 Valgrind is being weird so I can't test it on Linux, butI don't think it's platform-dependent. -- Summary: Value-initialization of POD base class doesn't initialize members Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gcc-bugzilla at kayari dot org GCC target triplet: sparc-sun-solaris2.9 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111