[Issue 12025] New: Wrong purity violation accessing the length of a fixed size array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 29 08:22:24 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12025

           Summary: Wrong purity violation accessing the length of a fixed
                    size array
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2014-01-29 08:22:21 PST ---
struct Foo {
    int[5] bar;
}
void main() pure {
    enum size_t n1 = typeof(Foo.bar).length; // OK
    enum size_t n2 = Foo.bar.length; // error
}


DMD 2.065beta gives a wrong error, because Foo.bar.length is a compile-time
constant that can't break purity:

test.d(6): Error: pure nested function 'main' cannot access mutable data 'bar'

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


More information about the Digitalmars-d-bugs mailing list