Closed Quuxplusone closed 14 years ago
Attached foo2.ii.bz2
(121285 bytes, application/x-bzip2): preproccessed file
Please try to reduce the test down to something more manageable.
Reduced test case 1:
#include <iostream>
template<typename T>
class PBuf : public std::basic_streambuf<T> {};
template<typename T>
class Pcommon : virtual public std::basic_ios<T> {
protected:
typedef PBuf<T> streambuf_type;
public:
streambuf_type*
rdbuf() const { return 0; }
};
template<typename T>
class I : virtual public std::basic_ios<T> {};
template<typename T>
class O : virtual public std::basic_ios<T> {};
template<typename T>
class IO : public I<T>, public O<T> {};
template<typename T>
class P : public IO<T>, public Pcommon<T> {};
void f() { P<char> p; p.rdbuf(); }
---
I will reduce it further.
More reduced:
template<typename T> struct Buf {};
template<typename T> class PBuf : public Buf<T> {};
template<typename T>
struct BaseIO { Buf<T>* rdbuf() const { return 0; } };
template<typename T>
struct Pcommon : virtual BaseIO<T> { PBuf<T>* rdbuf() const { return 0; } };
template<typename T> struct I : virtual BaseIO<T> {};
template<typename T> struct O : virtual BaseIO<T> {};
template<typename T> struct IO : I<T>, O<T> {};
template<typename T>
struct P : public IO<T>, public Pcommon<T> {};
void f() { P<char> p; p.rdbuf(); }
And more simple:
struct BaseIO { BaseIO* rdbuf() { return 0; } };
struct Pcommon : virtual BaseIO { int rdbuf() { return 0; } };
struct P : virtual BaseIO, Pcommon {};
void f() { P p; p.rdbuf(); }
---
GCC has no problem to compile this. GCC fails though if I remove one of these
"virtual".
(In reply to comment #5)
> And more simple:
>
> struct BaseIO { BaseIO* rdbuf() { return 0; } };
> struct Pcommon : virtual BaseIO { int rdbuf() { return 0; } };
> struct P : virtual BaseIO, Pcommon {};
>
> void f() { P p; p.rdbuf(); }
>
> ---
>
> GCC has no problem to compile this. GCC fails though if I remove one of these
> "virtual".
Wonderful, thank you! It appears that we aren't implementing C++
[class.member.lookup]p6, which says:
When virtual base classes are used, a hidden declaration can be reached along a path through the sub-object lattice that does not pass through the hiding declaration. This is not an ambiguity. The identical use with nonvirtual base classes is an ambiguity; in that case there is no unique instance of the name that hides all the others.
Fixed in r97640.
foo2.ii.bz2
(121285 bytes, application/x-bzip2)