[Issue 23814] [Codegen] Calling member function of extern(C++) class with multiple inheritance doesn't preserve the EBX register in some cases

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jun 16 01:11:57 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=23814

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com

--- Comment #6 from Walter Bright <bugzilla at digitalmars.com> ---
(In reply to RazvanN from comment #3)
>    6:   e8 00 00 00 00          call   b <_ZN9MainClass5func4Ev+0xb>
>    b:   58                      pop    eax
>    c:   05 02 00 00 00          add    eax,0x2

What this code is doing (regardless of whether it is EAX or EBX) is:

1. CALL: to the next instruction. This has the effect of pushing the address of
the next instruction on the stack

2. POP reg: puts that address into reg

3. ADD reg,xxxx: reg is now pointing to data that is relative to the code
section, likely a virtual function or a "thunk" to one

Can you try it with D classes rather than C++ classes?

--


More information about the Digitalmars-d-bugs mailing list