Bug 3621 – implicit conversion to const rules need tightening

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2009-12-16T13:28:00Z
Last change time
2015-06-09T01:27:03Z
Keywords
spec
Assigned to
nobody
Creator
bugzilla
Blocks
2573

Comments

Comment #0 by bugzilla — 2009-12-16T13:28:09Z
The following allows a write to an immutable array: import std.stdio; void doSomething(const(char)[][] a, const(char)[][] b) { a[0]=b[0]; } void main() { string s = "hello"; char[][1] a; string[1] b; b[0] = s; doSomething(a, b); a[0][1] = 'c'; // OOPS! writeln(s); } So, a conversion to const that is not the top ref should be disallowed.
Comment #1 by leandro.lucarella — 2009-12-16T16:17:10Z
Comment #2 by dfj1esp02 — 2009-12-17T03:12:12Z
Definitely duplicate of bug 2544.
Comment #3 by smjg — 2009-12-17T03:34:15Z
I must've assumed every account on this bugzilla had the editbugs bit set.... *** This issue has been marked as a duplicate of issue 2544 ***
Comment #4 by bugzilla — 2009-12-31T11:21:33Z
Fixed dmd 2.038