D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3621 - implicit conversion to const rules need tightening
Summary: implicit conversion to const rules need tightening
Status: RESOLVED DUPLICATE of issue 2544
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: spec
Depends on:
Blocks: 2573
  Show dependency treegraph
 
Reported: 2009-12-16 13:28 UTC by Walter Bright
Modified: 2015-06-09 01:27 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Walter Bright 2009-12-16 13:28:09 UTC
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 Leandro Lucarella 2009-12-16 16:17:10 UTC
http://www.dsource.org/projects/dmd/changeset/299
Comment 2 anonymous4 2009-12-17 03:12:12 UTC
Definitely duplicate of bug 2544.
Comment 3 Stewart Gordon 2009-12-17 03:34:15 UTC
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 Walter Bright 2009-12-31 11:21:33 UTC
Fixed dmd 2.038