Bug 20631 – Calling exit in module destructor yields undefined behaviour

Status
NEW
Severity
minor
Priority
P3
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-03-03T18:12:45Z
Last change time
2024-12-07T13:40:00Z
Assigned to
No Owner
Creator
moonlightsentinel
Moved to GitHub: dmd#17398 →

Comments

Comment #0 by moonlightsentinel — 2020-03-03T18:12:45Z
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)
Comment #1 by robert.schadek — 2024-12-07T13:40:00Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17398 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB