This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

egcs-980214 & pmf



Hello there,

I think the following code is legal, but g++ 2.7.2.1 and egcs-980214
produce an error message at the marked line

Machine is i486-pc-linux-gnulibc1, if that makes any difference.

Why the first case would compile ok, but the second won't seems
odd to me. I would have thought that they both would have failed,
or both would have succeeded.

struct A {
	int i;
	int f() { return i; }
};

struct B : public A {
};

int
main()
{
	int (B ::* pi);
	pi = &A::i;

	if (pi != &A::i)	// ok here
	{
		return 1;
	}

	int (B ::* pi2)();
	pi2 = &A::f;

	if (pi2 != &A::f)	// marked line
	{
		return 2;
	}

	return 0;
}


Regards

David Binderman MSc BSc    +44 1293 534 847       dcb_AVOID_JUNK_MAIL@pncl.co.uk
There is no substitute for skill, taste and experience when programming
 - Dr Stroustrup, inventor of C++



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]