August 25, 2020 [Issue 21198] New: Inout copy constructor on union field does not prevent copy-initialization of union | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=21198 Issue ID: 21198 Summary: Inout copy constructor on union field does not prevent copy-initialization of union Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: snarwin+bugzilla@gmail.com 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. -- |
Copyright © 1999-2021 by the D Language Foundation