[Issue 6654] New: Fixed-sized array length not accessible in pure functions
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 12 13:18:49 PDT 2011
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 at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2011-09-12 13:18:31 PDT ---
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: -------
More information about the Digitalmars-d-bugs
mailing list