[Issue 14051] New: Invariant gets invoked after destruction for structs with File members
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Mon Jan 26 07:52:39 PST 2015
    
    
  
https://issues.dlang.org/show_bug.cgi?id=14051
          Issue ID: 14051
           Summary: Invariant gets invoked after destruction for structs
                    with File members
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: bayan.rafeh92 at gmail.com
When a class with a File as a member of the class, the invariant block gets
invoked incorrectly, twice before destruction and once after destruction.
An example code snippet:
// Written by Ali Çehreli
import std.stdio;
void main(){
    writeln("entered main");
    auto a = new A();
    writeln("leaving main");
}
class A {
    File file;
    this() {
        writeln("this");
    }
    ~this() {
        writeln("~this");
    }
    invariant() {
        writeln("invariant");
    }
}
The previous code produces the following output:
entered main
this
invariant
leaving main
invariant
invariant    <-- ?
~this
invariant    <-- ?
The forum thread where this issue was found:
http://forum.dlang.org/thread/ossuvfmqthllgdpgzntm@forum.dlang.org
--
    
    
More information about the Digitalmars-d-bugs
mailing list