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: [email protected]
Reporter: [email protected]
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)
--