[Issue 21225] New: preview=dtorfields inserts unnecessary dtor call in nothrow ctors
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Sep 4 23:46:02 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21225
Issue ID: 21225
Summary: preview=dtorfields inserts unnecessary dtor call in
nothrow ctors
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: moonlightsentinel at disroot.org
The following code fails to compile with `-preview=dtorfields`:
======================================
struct Nothrow
{
~this() {}
}
struct NothrowConstructor
{
Nothrow member;
this(int) pure nothrow {}
}
======================================
Error: `pure` constructor `NothrowConstructor.this` cannot call impure
destructor `NothrowConstructor.~this`
The code currently fails to compile because the compiler rewrites the
user-defined constructor as:
try
<Old constructor>
catch (Exception e)
{
<Destructor>
throw e;
}
This causes the attribute missmatch (NothrowConstructor.~this not pure) albeit
the catch block is unreachable (unless the old constructor violates it's
`nothrow guarantee - which is UB anyway)
--
More information about the Digitalmars-d-bugs
mailing list