[Issue 10694] New: wrong purity check for static variables with impure destructor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 22 02:32:47 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10694

           Summary: wrong purity check for static variables with impure
                    destructor
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: monarchdodra at gmail.com


--- Comment #0 from monarchdodra at gmail.com 2013-07-22 02:32:44 PDT ---
//----
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list