www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6654] New: Fixed-sized array length not accessible in pure functions

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6654

           Summary: Fixed-sized array length not accessible in pure
                    functions
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



Severity is 'minor' because there is a simple workaround.

D2 code:


int[3] foo;
void main() pure {
    auto n = foo.length;
}


DMD 2.055 gives:
test.d(3): Error: pure function 'main' cannot access mutable static data 'foo'

But I think this code is correct because foo.length is a compile-time constant,
so it doesn't break the purity of the main.

Workaround:


int[3] foo;
void main() pure {
    auto n = typeof(foo).length;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 12 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6654




*** Issue 8690 has been marked as a duplicate of this issue. ***

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