"gcc version 4.4.0 20081123 (experimental) (GCC)" rejects the code:
class base {
public:
base();
virtual ~base();
private:
int& int_ref; // initialized by base ctor, not visible here
};
class derived : public base {
};
base *make_derived() {
return new derived();
}
with the error:
test.cc: In function 'base* make_derived()':
test.cc:14: error: value-initialization of reference
4.3.2 accepts this code, the Comeau test drive accepts it, and AFAICT there's
nothing wrong with it.
Adding a user-supplied default ctor to 'derived' fixes it.
This was build from a GCC trunk checkout as of this evening:
Using built-in specs.
Target: i686-linux
Configured with: ../trunk/configure --enable-languages=c,c++ --build=i686-linux
--host=i686-linux --target=i686-linux
--prefix=/g/users/cgd/proj/gcc-trunk/bld/../inst
Thread model: posix
gcc version 4.4.0 20081123 (experimental) (GCC)
--
Summary: "value-initialization of reference" warning too strict
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: cgd at google dot com
GCC build triplet: i686-linux
GCC host triplet: i686-linux
GCC target triplet: i686-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38232