Bug report
Martin v. Loewis
martin@mira.isdn.cs.tu-berlin.de
Sun Feb 28 23:30:00 GMT 1999
> I use egcs version 1.1.1 on kernel 2.0.36. In the class hierarchy
> shown below, when a pointer to an object of type Class is cast to
> type ChangeNotifier, an invalid pointer results. I'm desperate, so
> help would be much appreciated, thanks.
I could not reproduce this bug. Given the information you provided, I
completed your fragment to read
#include <cstdio>
#include <list>
class ChangeNotifier{
public:
int val;
ChangeNotifier():val(42){}
};
class Object{};
class HasName{};
class HasUniqueQualifier{};
class Registrable{};
class Streamable : public virtual Object {};
template <class T> class TypeCheckingList : public list<T*>,
public virtual Streamable, public virtual ChangeNotifier {};
class Entity : public virtual Object, public HasUniqueQualifier, public virtual
HasName, public virtual Streamable, public virtual
ChangeNotifier, public Registrable {};
typedef TypeCheckingList<Entity> EnclosesEntities;
class HasSettableName : public virtual HasName, public virtual Streamable,
public virtual ChangeNotifier {};
class IsType : public virtual Streamable {};
class StaticEntity : public Entity {};
class Structure : public StaticEntity, public IsType, public HasSettableName,
public EnclosesEntities {};
class Class : public Structure {};
void main()
{
Class c;
ChangeNotifier *x = &c;
printf("%d\n",x->val);
}
This should print 42. In my installation (egcs 2.91.60, on
i586-pc-linux-gnu), it does. So where is the problem?
Martin
More information about the Gcc-bugs
mailing list