[Issue 13147] New: Wrong codegen for thisptr in naked extern (C++) methods
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Jul 16 19:55:27 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13147
Issue ID: 13147
Summary: Wrong codegen for thisptr in naked extern (C++)
methods
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: me at philpax.me
Naked extern (C++) methods are missing "mov [EBP-4], ECX", resulting in a
failed invariant assertion ('null this'). This appears to be because the
instruction to load [EBP-4] with ECX is treated as part of the stack frame.
While it is expected that a stack frame is set up by the user in a naked
function, the invariant is tested before my inline assembly preventing me from
doing so.
This means that anything to do with 'this' in a naked extern (C++) fails to
work, as D looks for 'this' in the untouched [EBP-4]. A test case is below:
class Test
{
extern (C++) Test test()
{
asm { naked; }
return this;
}
}
When the above function is disassembled, the mov [EBP-4], ECX instruction will
be missing. When run, it will assert with "null this".
A related issue appears to be https://issues.dlang.org/show_bug.cgi?id=2350.
--
More information about the Digitalmars-d-bugs
mailing list