[Issue 18590] New: nothrow constructor call still type-checks destructor for purity
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Mar 11 15:33:30 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18590
Issue ID: 18590
Summary: nothrow constructor call still type-checks destructor
for purity
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P2
Component: dmd
Assignee: nobody at puremagic.com
Reporter: code at dawg.eu
cat > bug.d << CODE
extern(C) int printf(const char*, ...);
struct F
{
static F create() pure nothrow
{
return F(1);
}
this(int) pure nothrow
{
}
~this()
{
printf("~this\n");
}
}
CODE
dmd -c bug
----
Error: pure function 'bug.F.create' cannot call impure function 'bug.F.~this'
----
Apparently happens because `F(1)` is lowered to `(tmp = F(1)),tmp` internally.
https://github.com/dlang/dmd/blob/93804714c4091a8d867c09ca7b5bf332acb34dfb/src/dmd/expression.d#L3931
--
More information about the Digitalmars-d-bugs
mailing list