AlexBelo 12 Posted August 2, 2022 (edited) 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 August 2, 2022 by AlexBelo Share this post Link to post
Der schöne Günther 316 Posted August 2, 2022 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 [RSP-30762] [bcc32c]: fastcall calling convention ignored on constructor/destructor - Embarcadero Technologies [RSP-23671] Unexpected compiler error - Embarcadero Technologies [RSP-33071] [bcc32c error] virtual function '~XXX' has different calling convention attributes ('void ()') than the function it overrides (which has calling convention 'void () __attribute__((fastcall))') : overridden virtual function is here - Embarcadero Technologies 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
AlexBelo 12 Posted August 2, 2022 Thank you for additional information. __fastcall for overlapped virtual destructor of Delphi-based class in CLANG32 compiler https://quality.embarcadero.com/browse/RSP-38783 Share this post Link to post