-
-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C++ SysV ABI incompatibility wrt. passing non-PODs by value #2702
Comments
To play around with C++: https://godbolt.org/g/XV8Pem (try commenting out the copy ctor and see what happens) |
GDC, at least v5.2 as latest version on godbolt, is affected too. See this D snippet. D additionally doesn't call the C++ copy ctor when passing an lvalue by value, I thought that'd be implemented already. That can be worked around with a D postblit ctor though. Then there's the different destruction rules; D moves the arg (or arg copy for lvalues) to the callee's memory params stack and lets the callee destruct it, C++ passes a ref to the rvalue (or lvalue copy) to the callee and the calleR destructs it after the call. In frontend terms, a C++ non-POD by-value param is more like an exotic ref, accepting rvalue args and requiring a copy for lvalue args. Anyway, this explains why clang has no problems calling a move ctor, while LDC would probably have a hard time for DIP1014 with the current ABI (final address of callee param in IR only exposed to callee via implicit |
Fixing one aspect of issue ldc-developers#2702; not tackling the different destruction rules yet.
Fixing one aspect of issue ldc-developers#2702; not tackling the different destruction rules yet.
Fixing one aspect of issue ldc-developers#2702; not tackling the different destruction rules yet.
Non-PODs use the |
While checking assembly and clang-IR wrt. DIP 1014, I stumbled on what looks like a huge ABI incompatibility, at least for the SysV ABI, and probably the 32-bit x86 ABIs too (Win64 should be safe though).
As soon as a C++ struct/class has a copy or move ctor, pass-by-value semantics seem to match
ExplicitByvalRewrite
(pass a pointer to a caller-allocated copy). LDC and DMD instead pass the aggregate on the stack (i.e., like a big POD struct). More information to follow.The text was updated successfully, but these errors were encountered: