Bug 6654 – Fixed-sized array length not accessible in pure functions

Status
RESOLVED
Resolution
DUPLICATE
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2011-09-12T13:18:00Z
Last change time
2015-02-23T03:37:04Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-09-12T13:18:31Z
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; }
Comment #1 by yebblies — 2013-01-16T07:34:55Z
*** Issue 8690 has been marked as a duplicate of this issue. ***
Comment #2 by k.hara.pg — 2015-02-23T03:37:04Z
*** This issue has been marked as a duplicate of issue 12025 ***