[Issue 21349] copy and postblit constructors aren't compatible

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 11 02:18:37 UTC 2020


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

--- Comment #8 from RazvanN <razvan.nitu1305 at gmail.com> ---
(In reply to Paul Backus from comment #5)
> When an aggregate has both old and new style members, the compiler generates
> both a copy constructor and a postblit, and the postblit takes precedence.
> 
> I agree that this is a bug in the language design: the generated copy
> constructor will call the members' postblits, so it should be the one that
> takes precedence.

No, it does not generate both. It first looks for user defined postblits in the
struct or in its fields and if it finds any, it will ignore user defined copy
constructors. So in this case, C will not have a copy constructor because what
the user wants takes precedence over generated methods.

--


More information about the Digitalmars-d-bugs mailing list