This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/25811] No failure creating a POD containing a const member, using new without a new-initializer.
- From: "fabien dot chene at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 Mar 2010 07:06:30 -0000
- Subject: [Bug c++/25811] No failure creating a POD containing a const member, using new without a new-initializer.
- References: <bug-25811-12027@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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