BUG:cannot convert a pointer

Dr. Joern v. Holten jvh@megatel.de
Mon Aug 2 00:43:00 GMT 1999


>From my point of view this one is a bug: lines 16 and 17 of
my sample should mean the same. Not using -pedantic 'solves'
the problem.

$gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95/specs
gcc version 2.95 19990728 (release)

$gcc a.cpp -pedantic
a.cpp: In method `void E::f()':
a.cpp:17: cannot convert a pointer of type `E' to a pointer of type `A'
a.cpp:17: because `A' is an ambiguous base class

a.cpp:
---------------------snip-----------------------------
class A
{
  public:
  void f() {}
};

class B : public A {};
class C : public A {};
class D : public C {};

class E : public D, public B
{
  public:
  void f()
  {
    static_cast<D*>(this)->f(); // this works
    D::f();			// and this does not
  }
};

int main() { return 0; }

-- 
 _____ 
|     |     Dr. Jörn von Holten
|     `.__  megatel Informations- und Kommunikationssysteme GmbH
|         | Wiener Str. 3    *     28359 Bremen    *     Germany
| megatel | Phone:  +49 421 22095-0   *   Fax:  +49 421 22095-16
`---------' eMail:  jvh@innocent.com  *    http://www.megatel.de

Truth of the day: Managers, not engineers, rule the world.
Trust the computer industry to shorten "Year 2000" to Y2K. It was
this kind of thinking that caused the problem in the first place.


More information about the Gcc-bugs mailing list