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]

Re: Bug report


> 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


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