Bug 11286 – Impure dtor makes "cannot call impure function" error, although it won't actually be called.
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-17T01:36:00Z
Last change time
2013-11-07T20:09:48Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2013-10-17T01:36:48Z
From: http://forum.dlang.org/thread/[email protected]
=====================================
I get this error:
----
/d701/f223.d(11): Error: pure function 'f223.getA' cannot call
impure function 'f223.A.~this'
----
with this code:
----
import std.stdio;
struct A {
public:
~this() {
writeln("DTor");
}
}
A getA() pure nothrow {
return A();
}
void main()
{
A a = getA();
writeln("end of main");
}
----
But without pure and nothrow I get this output:
----
end of main
DTor
----
Why the compiler thinks that the function should/could call
A::~this?