Bug 3290 – accepts-invalid: non-const by-ref foreach over a const array is accepted
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2009-09-03T13:12:00Z
Last change time
2012-06-03T03:52:23Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
2korden
Comments
Comment #0 by 2korden — 2009-09-03T13:12:35Z
The following test-case shouldn't compile:
void main()
{
const(int)[] array;
foreach (ref int i; array) {
// i = 42;
}
}
Note that modifying the 'i' is still prohibited.
Comment #1 by bearophile_hugs — 2010-07-26T12:27:44Z