Bug 21223 – nothrow constructor may call throwing constructor with

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-09-04T07:53:08Z
Last change time
2024-12-13T19:11:21Z
Assigned to
No Owner
Creator
moonlightsentinel
Moved to GitHub: dmd#19780 →

Comments

Comment #0 by moonlightsentinel — 2020-09-04T07:53:08Z
Consider the following example: ============================================================== struct HasDtor { ~this() { // Enforce @system, ... just to be sure __gshared int i; if (++i) throw new Exception(new immutable(char)[](10)); } } // The user-defined dtor matches the ctor attributes struct Strict { HasDtor member; this(int) pure nothrow @nogc @safe {} ~this() pure nothrow @nogc @safe {} } ============================================================== Compiling this code with `-preview=dtorfields` will insert a potential call to HasDtor.~this into Strict.this. This is obviously an error because the destructor doesn't match the attributes enforced by the constructor, yet only pure nothrow @nogc will be reported while non-nothrow is accepted.
Comment #1 by moonlightsentinel — 2020-09-04T17:42:27Z
(In reply to moonlightsentinel from comment #0) > [...] only pure nothrow @nogc will be reported while non-nothrow is accepted. Typo, only pure __@safe__ @nogc will be reported
Comment #2 by robert.schadek — 2024-12-13T19:11:21Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19780 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB