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.
Comment #1 by henning — 2013-07-22T14:59:13Z
Comment #2 by github-bugzilla — 2013-07-24T20:35:46Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/33dda1f177478c34113b47dcd24cd54c08100cb4 fix issue 10694 - wrong purity check for static variables with impure destructor https://github.com/D-Programming-Language/dmd/commit/2b1bc0eea17bd2f7497f73285d3411079844c704 Merge pull request #2373 from hpohl/10694 fix issue 10694 - wrong purity check for static variables with impure destructor