Bug 19099 – Struct with field that has postblit or destructor makes struct assignable

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-07-19T12:29:54Z
Last change time
2019-04-09T10:50:19Z
Keywords
pull
Assigned to
No Owner
Creator
RazvanN

Comments

Comment #0 by razvan.nitu1305 — 2018-07-19T12:29:54Z
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
Comment #1 by bugzilla — 2018-07-21T06:39:49Z
Comment #2 by dlang-bot — 2019-04-05T11:15:38Z
@RazvanN7 updated dlang/dmd pull request #8507 "Fix Issue 19099 - Struct with field that has postblit or destructor makes struct assignable" fixing this issue: - Fix Issue 19099 - Struct with field that has postblit or destructor makes struct assignable https://github.com/dlang/dmd/pull/8507
Comment #3 by dlang-bot — 2019-04-09T10:50:19Z
dlang/dmd pull request #8507 "Fix Issue 19099 - Struct with field that has postblit or destructor makes struct assignable" was merged into master: - f88884200b332e373448f366638e3a40f99dd1c7 by RazvanN7: Fix Issue 19099 - Struct with field that has postblit or destructor makes struct assignable https://github.com/dlang/dmd/pull/8507