Bug 4510 – [tdpl] ref with a wrong type specifier is accepted
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-07-26T12:02:00Z
Last change time
2012-06-02T20:50:57Z
Keywords
accepts-invalid, pull, TDPL, wrong-code
Assigned to
nobody
Creator
andrej.mitrovich
Comments
Comment #0 by andrej.mitrovich — 2010-07-26T12:02:01Z
Taken from TDPL, the following test-case shouldn't compile:
void main() {
float[] arr = [1.0, 2.5, 4.0];
foreach (ref double elem; arr) {
elem /= 2;
}
}
Comment #1 by bearophile_hugs — 2010-07-26T12:28:09Z
See also bug 3290
Comment #2 by andrej.mitrovich — 2011-05-19T19:28:18Z
Should I add a wrong-code keyword to this?
Floats might be implicitly convertible to double, however the foreach loop doesn't actually modify the arr array.