www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19099] New: Struct with field that has postblit or destructor


          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);
    A b = A(3);
    a = b;            // line 21

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:


Jul 19 2018