Add deleting destructor for c++ ABI #303
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implicitly emit the deleting destructor for extern "c++" mangling for better g++ ABI compatibility
In an
extern "c++"block, fbc will allocate an entry in the virtual table (if it has one) for the deleting destructor:Example:
When user defines a complete destructor (typical in fbc), the deleting destructor will also be implicitly generated:
Where the
deleteoperator will first invoke the complete destructor (~T::T()) followed by deallocating the memory.Some simple tests have been added to check the usage of passing an fbc declared type to a g++ implemented class, however the tests are quite simple and do not fully explore virtual tables and inheritance. More testing is needed. However, the change should not adversely effect non
extern "c++"source codes.Note: without support for
thiscallcalling convention, this is not expected to work on 32-bit windows where the default calling convention isthiscallfor c++ classes by default.References:
sf.net: #923 Incompatibility in ABI destructor with GCC C++
fb.net: C++ ABI Compatible?
Background:
Previously, fbc did not add the deleting destructor to the type's virtual table making it difficult to use (some) g++ compiled code directly.