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.
Comment #3 by k.hara.pg — 2012-06-01T09:57:46Z
Comment #4 by github-bugzilla — 2012-06-02T15:22:04Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/4591279a8c2630d03fc5a18cd326ce19ecc4dd93 fix Issue 4510 - [tdpl] ref with a wrong type specifier is accepted https://github.com/D-Programming-Language/dmd/commit/62d6363c59362025b0c809ee865dd52d78cbf33c Merge pull request #977 from 9rnsr/fix_foreach_arg Issue 3290,4510,5435 - Add strict type check for foreach argument