[Issue 20367] New: Postblit cannot be disabled when copy ctor is defined
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Nov 7 22:29:06 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=20367
Issue ID: 20367
Summary: Postblit cannot be disabled when copy ctor is defined
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: fanda.vacek at volny.cz
import std.stdio;
struct A
{
int x;
this(ref return scope A rhs)
{
writeln("copy ctor: ", x);
}
@disable this(this) {writeln("postblit: ", x); }
}
void main()
{
A a;
A b = a; // copy constructor gets called
}
I've got error: Error: struct `tst.A` is not copyable because it is annotated
with `@disable`
but it should not be used according to
https://dlang.org/spec/struct.html#struct-postblit
WARNING: The postblit is considered legacy and is not recommended for new code.
Code should use copy constructors defined in the previous section. For backward
compatibility reasons, a struct that defines both a copy constructor and a
postblit will only use the postblit for implicit copying.
--
More information about the Digitalmars-d-bugs
mailing list