Bug 14051 – Invariant gets invoked after destruction for structs with File members

Status
NEW
Severity
enhancement
Priority
P4
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-01-26T15:52:39Z
Last change time
2024-12-07T13:34:42Z
Assigned to
No Owner
Creator
Bayan Rafeh
Moved to GitHub: dmd#17138 →

Comments

Comment #0 by bayan.rafeh92 — 2015-01-26T15:52:39Z
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/[email protected]
Comment #1 by k.hara.pg — 2015-01-26T16:01:57Z
Maybe related: https://github.com/D-Programming-Language/druntime/pull/864 I think it's druntime issue.
Comment #2 by robert.schadek — 2024-12-07T13:34:42Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17138 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB