Bug 12025 – Wrong purity violation accessing the length of a fixed size array

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-29T08:22:00Z
Last change time
2015-02-23T03:37:04Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2014-01-29T08:22:21Z
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'
Comment #1 by k.hara.pg — 2014-02-20T00:45:42Z
Comment #2 by github-bugzilla — 2014-02-20T15:25:17Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/50bcf60631f2f03a9f2e6d200052ec0a615953c1 fix Issue 12025 - Wrong purity violation accessing the length of a fixed size array https://github.com/D-Programming-Language/dmd/commit/559ad04e6d9cf444a0104eea32e45b68f5016e7a Merge pull request #3303 from 9rnsr/fix12025 Issue 12025 - Wrong purity violation accessing the length of a fixed size array
Comment #3 by k.hara.pg — 2015-02-23T03:37:04Z
*** Issue 6654 has been marked as a duplicate of this issue. ***