digitalmars.D.bugs - [Issue 20631] New: Calling exit in module destructor yields
- d-bugmail puremagic.com (48/48) Mar 03 2020 https://issues.dlang.org/show_bug.cgi?id=20631
https://issues.dlang.org/show_bug.cgi?id=20631 Issue ID: 20631 Summary: Calling exit in module destructor yields undefined behaviour Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: minor Priority: P1 Component: druntime Assignee: nobody puremagic.com Reporter: moonlightsentinel disroot.org The following snippet yields inconsistent behaviour depending on the current platform: ------------------------------------------- import core.stc.stdlib : exit; import core.stdc.stdio : printf; struct X() { static ~this() { printf("~this()\n"); fflush(stdout); exit(0); } } static ~this() { printf("g: ~this()\n"); fflush(stdout); } int main() { alias X!() x; return 1; } ------------------------------------------- Win64: -------------- ~this() -------------- Exit status 0 Some posix platforms: -------------- ~this() g: ~this() -------------- Exit status 0 (???) (Extracted from runnable/test52.d in DMDs test suite) --
Mar 03 2020