2

A package using multiple inheritance causes an Access Violation in C++Builder 10.1 Berlin Update 2 using the CLANG based 32-bit and 64-bit compilers.

As soon as the class with multiple inheritance has implementation code, CLANG causes an ICE.

Here is a simple code that will trigger the problem:

// vcl
#include <System.Classes.hpp>

class TClass1
{
public:
    virtual __fastcall ~TClass1() = 0;
};

class PACKAGE TDummy :  public TComponent, public TClass1
{
public:
    /**
    * Pure virtual VCL style destructor
    *@note Needed to allow WTControlObserver destruction directly (otherwise children destructors
    *      are never called)
    */
    virtual __fastcall ~TDummy()
    {}

    void __fastcall test();
};

And implementation (must be in CPP):

void __fastcall TDummy::test()
{
    int i = 0;
}

I wrote to Embarcadero multiple times, without any luck. We are stuck since our projects can't compile without this.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Louka
  • 152
  • 10
  • I am just guessing it could be related to old compiler bug inherited from older versions of Builder. If the case this should help: [bds 2006 C hidden memory manager conflicts](http://stackoverflow.com/a/18016392/2521214) adding that to each `const/struct` solves a lot of problems (in both runtime and compile time) in older compiler versions. For example like this: [Too many initializers error for a simple array in bcc32](http://stackoverflow.com/q/33829983/2521214). Let me know if it helps (I do not use the newer versions yet) – Spektre Mar 04 '17 at 08:22
  • 1
    Do you have the same problem if you remove the abstract destructor from `TClass1`? It is not being used for anything, and `TComponent` already exposes a virtual destructor (you don't need to declare an empty destructor). You have to be careful when using multiple inheritance with `TObject`-derived classes (like `TComponent`) because `TObject` is implemented in Delphi, and Delphi does not support multiple inheritance of classes, only interfaces. In C++Builder, a `TObject`-derived class can only use multiple inheritance of abstract classes that have no implementations of their own. – Remy Lebeau Mar 21 '17 at 17:14

0 Answers0