Bug 20367 – Postblit cannot be disabled when copy ctor is defined
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2019-11-07T22:29:06Z
Last change time
2019-11-11T10:08:17Z
Keywords
pull
Assigned to
No Owner
Creator
Fanda Vacek
Comments
Comment #0 by fanda.vacek — 2019-11-07T22:29:06Z
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.
Comment #1 by dlang-bot — 2019-11-11T09:02:30Z
@RazvanN7 created dlang/dmd pull request #10557 "Fix Issue 20367 - Postblit cannot be disabled when copy ctor is defined" fixing this issue:
- Fix Issue 20367 - Postblit cannot be disabled when copy ctor is defined
https://github.com/dlang/dmd/pull/10557
Comment #2 by dlang-bot — 2019-11-11T10:08:17Z
dlang/dmd pull request #10557 "Fix Issue 20367 - Postblit cannot be disabled when copy ctor is defined" was merged into master:
- 84a12c0685f6f87d87dcdcf143b886595d031542 by RazvanN7:
Fix Issue 20367 - Postblit cannot be disabled when copy ctor is defined
https://github.com/dlang/dmd/pull/10557