From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26005 invoked by alias); 31 Mar 2010 07:07:05 -0000 Received: (qmail 25856 invoked by uid 48); 31 Mar 2010 07:06:30 -0000 Date: Wed, 31 Mar 2010 07:07:00 -0000 Message-ID: <20100331070630.25855.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/25811] No failure creating a POD containing a const member, using new without a new-initializer. In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "fabien dot chene at gmail dot com" 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: 2010-03/txt/msg03105.txt.bz2 ------- Comment #7 from fabien dot chene at gmail dot com 2010-03-31 07:06 ------- (In reply to comment #6) > (In reply to comment #5) > > > Nevertheless, can you confirm that it is valid C++03 ? > > > > I mean invalid, sorry. > > Yup :-) > > It is invalid. A is a non-POD class type, so 5.3.4/15 says the new-expression > without a new-initializer causes the object to be default-initialized, which > causes a default constructor to be implicitly-defined with an empty > mem-initializer list (12.1/7) which is ill-formed by 8.5/5 because the > reference member is not initialized. > > > In C++03 the cases of Foo and A are slightly different, "new Foo" is ill-formed > according to 5.3.4/15 and "new A" is ill-formed as described above. Thanks for the clarification ! Patch here for the non C++0X part: http://gcc.gnu.org/ml/gcc-patches/2010-03/msg01467.html > In C++0x both "new Foo" and "new A" result in a call to a deleted constructor. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25811