Bug 18986 – OSX/FreeBSD: allocating an instance of a C++ class fails

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2018-06-14T06:30:13Z
Last change time
2024-12-13T18:59:09Z
Assigned to
No Owner
Creator
Rainer Schuetze
Moved to GitHub: dmd#17864 →

Comments

Comment #0 by r.sagitario — 2018-06-14T06:30:13Z
When allocating a C++ class instance with the constructor defined in C++, the wrong object address is used: // testcpp.cpp class Cpp { public: Cpp(); virtual void foo() {} int x; }; Cpp::Cpp() { x = 42; } // testd.d extern(C++) { class Cpp { public: this(); void foo(); int x; } } void main() { Cpp c = new Cpp; assert(c.x == 42); } The assertion fails for OSX and FreeBSD, but not on Windows and Linux. This happens because the constructor does not return 'this' on the former platforms.
Comment #1 by robert.schadek — 2024-12-13T18:59:09Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17864 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB