Bug 21198 – Inout copy constructor on union field does not prevent copy-initialization of union

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-08-25T16:26:35Z
Last change time
2020-09-11T06:12:25Z
Keywords
pull
Assigned to
No Owner
Creator
Paul Backus

Comments

Comment #0 by snarwin+bugzilla — 2020-08-25T16:26:35Z
Example program: --- struct S { this(ref inout(S) other) inout {} } union U { S s; } static assert(!__traits(compiles, (U original) { U copy = original; } )); --- The language spec says: > If a union S has fields that define a copy constructor, whenever an object of > type S is initialized by copy, an error will be issued. The same rule applies > to overlapped fields (anonymous unions). According to this paragraph, the static assert above should pass. However, as of DMD 2.093.1, it fails.
Comment #1 by dlang-bot — 2020-08-27T23:14:49Z
@pbackus created dlang/dmd pull request #11634 "Fix issue 21198 - Inout copy constructor on union field does not prev…" fixing this issue: - Fix issue 21198 - Inout copy constructor on union field does not prevent copy-initialization of union Previously, generated copy constructors of unions were disabled only if they failed to type-check. They are now disabled in all cases, as required by the language spec. https://github.com/dlang/dmd/pull/11634
Comment #2 by dlang-bot — 2020-08-29T18:49:32Z
dlang/dmd pull request #11634 "Fix issue 21198 - Inout copy constructor on union field does not prev…" was merged into stable: - 573bf6a171f5dd23caebda7bb2ca66455c3d6d0f by Paul Backus: Fix issue 21198 - Inout copy constructor on union field does not prevent copy-initialization of union Previously, generated copy constructors of unions were disabled only if they failed to type-check. They are now disabled in all cases, as required by the language spec. https://github.com/dlang/dmd/pull/11634
Comment #3 by dlang-bot — 2020-09-11T06:12:25Z
dlang/dmd pull request #11718 "merge stable" was merged into master: - f602545af9c0db08b70a8ff2372515416c1a2d2a by Paul Backus: Fix issue 21198 - Inout copy constructor on union field does not prevent copy-initialization of union Previously, generated copy constructors of unions were disabled only if they failed to type-check. They are now disabled in all cases, as required by the language spec. https://github.com/dlang/dmd/pull/11718