July 19, 2018 [Issue 19099] New: Struct with field that has postblit or destructor makes struct assignable | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19099 Issue ID: 19099 Summary: Struct with field that has postblit or destructor makes struct assignable Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: razvan.nitu1305@gmail.com struct B { //this(this) {} //~this() {} int a; } struct A { B b; immutable int a; this(int b) { a = b;} } void main() { import std.stdio : writeln; A a = A(2); writeln(a.a); A b = A(3); a = b; // line 21 writeln(a.a); } This code correctly yields : bug.d(21): Error: cannot modify struct a A with immutable members However, if the postblit or the destructor or commented (or both), the code compiles successfully and when ran it prints: 2 3 -- |
Copyright © 1999-2021 by the D Language Foundation