-
-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
Area-OutputGenerationIssues concerning the process of generating output from BiohazrdIssues concerning the process of generating output from BiohazrdBlocks-PhysXConcept-CppFeaturesIssues concerning unsupported C++ featuresIssues concerning unsupported C++ featuresConcept-InlineExpectationIssues concerning problems around C++'s expectation for something to be inlined.Issues concerning problems around C++'s expectation for something to be inlined.Concept-OutputUsabilityIssues concerning whether or not the output from Biohazrd is actually usableIssues concerning whether or not the output from Biohazrd is actually usable
Description
For types without constructors, the C++ compiler may initialize the vtable pointer wherever the type is initialized.
This was encountered with PxDefaultAllocator.
Here's a simple example: (Godbolt)
class AbstractBase
{
public:
virtual void* allocate(int size);
};
class DefaultImpl : public AbstractBase
{
public:
void* allocate(int size)
{
return nullptr;
}
};
void UseAllocator(AbstractBase* allocator)
{
allocator->allocate(100);
}
void Test()
{
DefaultImpl impl;
UseAllocator(&impl);
}With GCC x86-64 10.2, Test is generated as follows:
Test():
push rbp
mov rbp, rsp
sub rsp, 16
mov eax, OFFSET FLAT:vtable for DefaultImpl+16
mov QWORD PTR [rbp-8], rax
lea rax, [rbp-8]
mov rdi, rax
call UseAllocator(AbstractBase*)
nop
leave
retThe easiest solution here is probably to use C trampolines for object construction (when necessary?)
Metadata
Metadata
Assignees
Labels
Area-OutputGenerationIssues concerning the process of generating output from BiohazrdIssues concerning the process of generating output from BiohazrdBlocks-PhysXConcept-CppFeaturesIssues concerning unsupported C++ featuresIssues concerning unsupported C++ featuresConcept-InlineExpectationIssues concerning problems around C++'s expectation for something to be inlined.Issues concerning problems around C++'s expectation for something to be inlined.Concept-OutputUsabilityIssues concerning whether or not the output from Biohazrd is actually usableIssues concerning whether or not the output from Biohazrd is actually usable