[Bug c++/26024] New: Initializing using methods of class object passed to constructor
Don at Skyler dot com
gcc-bugzilla@gcc.gnu.org
Mon Jan 30 05:14:00 GMT 2006
#include <iostream>
struct B1
{
B1(int i):i_(i) { }
int i_;
};
struct B2
{
B2 (void) { }
};
struct Initializer
{
B1 b1(void) const { return B1(1); }
B2 b2(void) const { return B2(); }
};
struct D : public B1, public B2
{
D ( const Initializer &init ) :
B1(init.b1()), B2(init.b2()) { }
};
int main (void)
{
d(Initializer());
// The line above produces the following error in g++ 3.4.4 under cygwin:
// bug.cpp: In function `int main()':
// bug.cpp:35: error: request for member `i_' in `d', which is of
non-class type `D
// ()(Initializer (*)())'
// Commenting out that line and uncommenting the following two lines:
// Initializer init;
// D d(init);
// compiles without error in g++ 3.4.4 under cygwin, but produces the
output:
// i_=0
// Under MS Visual C++ 6.0 either one compiles without error and produces:
// i_=1
// which appears to be correct.
std::cout << "i_=" << d.i_ << std::endl;
return 0;
}
--
Summary: Initializing using methods of class object passed to
constructor
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Don at Skyler dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26024
More information about the Gcc-bugs
mailing list