[Issue 4338] Structs with non-const destructors cannot be used as const parameters
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Tue Jul 25 03:09:40 PDT 2017
    
    
  
https://issues.dlang.org/show_bug.cgi?id=4338
ag0aep6g at gmail.com changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g at gmail.com
--- Comment #9 from ag0aep6g at gmail.com ---
(In reply to Andrei Alexandrescu from comment #6)
> Mutable destructors shouldn't apply to objects that were immutable,
> otherwise they can mutate immutable objects. Consider:
> 
> struct A {
>     int* p;
>     ~this() { *p = 5; }
> }
> 
> void main() {
>     auto p = new immutable(int);
>     { auto a = immutable(A)(p); }
>     assert(*p == 0);
> }
Dedicated issue for that: issue 17682.
--
    
    
More information about the Digitalmars-d-bugs
mailing list