Qualified destructors / immutable objects

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jun 12 04:13:18 PDT 2015


     struct S {
         int x;
         ~this() {
             import std.stdio;
             writeln("mutable ~this()");
             x = 1;
         }
     }

     void main() {
         const(S) s1;
         immutable(S) s2;
     }

Prints:

     mutable ~this()
     mutable ~this()

This looks very wrong, although I cannot find a way to actually 
modify immutable memory with it...

Is it a bug?


More information about the Digitalmars-d-learn mailing list