Bug 10694 – wrong purity check for static variables with impure destructor
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-22T02:32:00Z
Last change time
2013-07-24T20:36:05Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
monarchdodra
Comments
Comment #0 by monarchdodra — 2013-07-22T02:32:44Z
//----
import std.stdio;
struct Foo
{
~this()
{
writeln("destroyed");
}
}
void bar() pure
{
static Foo i; //(13)
}
void main()
{
bar();
}
//----
main.d(13): Error: pure function 'main.bar' cannot access mutable static data 'i'
main.d(13): Error: pure function 'main.bar' cannot call impure function 'main.Foo.~this'
//----
Because i is static, its destructor should never be called, so bar should not be concerned that i's destructor is not pure.