This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Legal c++ one-liner doesn't compile with gcc 2.95.2
- To: hymie at prolifics dot com
- Subject: Re: Legal c++ one-liner doesn't compile with gcc 2.95.2
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Tue, 11 Jul 2000 00:26:41 +0200
- CC: gcc-bugs at gcc dot gnu dot org
- References: <200007102025.e6AKPKY04727@calumny.jyacc.com>
> This is derived from code by Scott Meyers -
>
> ------------------
> const class { } a;
> ------------------
>
> g++ reports
>
> 1: uninitialized const `a'
Thanks for your bug report. I believe this is not a bug in g++, but in
your program, 8.5/9 says
# If no initializer is specified for an object, and the object is of
# (possibly cvqualified) nonPOD class type (or array thereof), the
# object shall be defaultinitialized; if the object is of
# constqualified type, the underlying class type shall have a
# userdeclared default constructor.
I'm not exactly sure how to read this, to me, it reads as
If no initializer is specified (NIIS) and if the object is of
const-qualified type (OOCQT) , then the class type shall have a
user-declared default constructor (SHUDDC)
- which this class doesn't have, so the program ill-formed.
Perhaps its intended meaning is
If NIIS and the object is of non-POD class type and OOCQT, then SHUDDC.
In this case, one of the preconditions would not hold, so the rest of
8.5/9 would apply
# Otherwise, if no initializer is specified for an object, the object
# and its subobjects, if any, have an indeterminate initial value; if
# the object or any of its subobjects are of constqualified type, the
# program is illformed.
No initializer is specified, and the object is of const-qualified
type, so the program is ill-formed.
Regards,
Martin