[Lldb-commits] [lldb] r114095 - in /lldb/trunk/include/lldb: Core/Debugger.h Target/Process.h Target/Thread.h

John McCall rjmccall at apple.com
Thu Sep 16 16:04:24 PDT 2010


On Sep 16, 2010, at 10:54 AM, Caroline Tice wrote:
> Okay I will work on re-doing the code so it doesn't have to do that.   For the record, the code as is works
> just fine on Mac OS X; I had no idea it would die so horribly on other platforms.

It really shouldn't die horribly on any platform, although some compilers will warn about it, particularly in the initializer lists.

There's something important and non-obvious to consider, though:  in C++, virtual calls during the constructor will call the most-derived methods as seen from the class being constructed.  For example, consider these class definitions:
  struct A {
    virtual void foo();
    virtual void bar() = 0;
    A();
  };
  struct B : A {
    virtual void foo();
    virtual void bar();
  };

Now consider the constructor for A:
  A::A() {
    foo(); // calls A::foo(), not B::foo()
    bar(); // calls A::foo(), which is pure virtual, which causes the program to terminate
  }

Just something to be aware of.

John.



More information about the lldb-commits mailing list