Jump to content
AlexBelo

__fastcall for overlapped virtual destructor of Delphi base class in CLANG compiler

Recommended Posts

HI all.

 

RAD 11.1.5

 

Consider the following code:

class dExc : public TObject
{
 public:
  static int Counter;
  dExc() { Counter++; printf(" dExc\n"); }
  /* __fastcall */ ~dExc() { Counter--; printf("~dExc\n"); }
};

int dExc::Counter=0;

If I compile this in "classic" mode without __fastcall I get:

[bcc32 Error] Main.cpp(19): E2113 Virtual function '~dExc::dExc()' conflicts with base class 'TObject'

 

CLANG-32 compiler shows "Success", but program crashes in destructor of ~dExc.

 

Adding __fastcall produces workable exe in both cases.

(CLANG-64 version works with and without __fastcall because 64-bit uses its own call convention AFAIK)

 

Is this a bug in CLANG-32 compiler?

 

Edited by AlexBelo

Share this post


Link to post

Yes, __fastcall has zero effect on x64 and ARM, compilers will usually just ignore it.

 

It seems ctors/dtors are a special case when it comes to calling conventions.

 

See

 

From what I gathered, Embarcadero maintained their own patch queue of modifications for clang so that calling conventions were handled also for constructors/destructors but appearantly, they are struggling to keep up with clang development.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×