[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#195468: g++-3.3: default construction fails when no explicit default constructor defined



On Sat, 2003-05-31 at 10:35, Martin v. Löwis wrote:
> Herbert Valerio Riedel <hvr@se-linux.ifs.tuwien.ac.at> writes:
> > ...so... is _still_ not a buggy behaviour??
> 
> No. Look at 8.5/9:
> 
> # If no initializer is specified for an object, and the object is of
> # (possibly cv-qualified) non-POD class type (or array thereof), the
> # object shall be default-initialized; if the object is of
> # const-qualified type, the underlying class type shall have a
> # user-declared default constructor.
[..]
# Otherwise, if no initializer is specified for anobject, the object 
# and its subobjects, if any, have an indeterminate initial value; if
# the object or any of its subobjects are of const-qualified type, the
# program is ill-formed.

> Your objects have const-qualified type, and the underlying class has
> no user-declared default constructor, hence your program is
> ill-formed. 

alright, then g++'s fault is to fail to recognize the ill-formed-ness of
at least the following cases, happily succeeds compiling them...:

struct foo {
  virtual void f(void);
};

struct bar {
  bar (); // user defined default constructor
};

struct doo {
  bar m_bar; // non-POD member w/ u.d.d.c
};

struct zoo: public bar { }; // inherited u.d.d.c

const foo a_foo; // ill-formed - foo has no user-declared def-cons
const bar a_bar; // ok
const doo a_doo; // ill-formed - doo has no user-declared def-cons
const zoo a_zoo; // ill-formed? not sure about this one...

reagards,
-- 
Herbert Valerio Riedel       /    Phone: (EUROPE) +43-1-58801-18840
Email: hvr@hvrlab.org       /    Finger hvr@gnu.org for GnuPG Public Key
GnuPG Key Fingerprint: 7BB9 2D6C D485 CE64 4748  5F65 4981 E064 883F 4142




Reply to: