[Issue 19099] New: Struct with field that has postblit or destructor makes struct assignable
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Thu Jul 19 12:29:54 UTC 2018
    
    
  
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 at puremagic.com
          Reporter: razvan.nitu1305 at 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
--
    
    
More information about the Digitalmars-d-bugs
mailing list