Hello, I wrote a simple D program to test the immutable attribute and discovered that by using standard input I could change immutable data, see code below.
import std.stdio;
void main() {
//Initialize string buf
immutable char[] buf = "hello";
writefln("buf = %s",buf);
//Change value of buf with standard input
stdin.readln(buf);
writefln("buf = %s",buf);
}
Cheers
Robert
Comment #1 by schveiguy — 2011-01-26T13:10:21Z
*** Issue 5492 has been marked as a duplicate of this issue. ***
Comment #2 by andrei — 2011-01-26T13:14:44Z
Reduced to:
void main()
{
immutable char[] buf = "hello";
void fun(ref immutable(char)[] a) {}
fun(buf);
}
This is a major bug. Please vote. Walter, it would be great if you gave this the utmost attention.
Comment #3 by hoganmeier — 2011-01-26T13:28:59Z
Seems to compile on all platforms.
Runs fine on Windows.
Segfaults on Linux, doesn't when using 'string buf' instead.
Comment #4 by yebblies — 2011-01-26T18:27:06Z
*** Issue 5273 has been marked as a duplicate of this issue. ***
Comment #5 by yebblies — 2011-01-26T18:27:09Z
*** Issue 4832 has been marked as a duplicate of this issue. ***
Comment #6 by yebblies — 2011-01-26T18:27:18Z
*** Issue 5291 has been marked as a duplicate of this issue. ***
Comment #7 by yebblies — 2011-01-26T18:27:24Z
*** Issue 4416 has been marked as a duplicate of this issue. ***
Comment #8 by yebblies — 2011-01-26T18:27:29Z
*** Issue 3534 has been marked as a duplicate of this issue. ***
Comment #9 by yebblies — 2011-01-26T18:29:19Z
Others marked as duplicates as this is the version that has the most votes, highest priority and is the only one that has been assigned.
Comment #10 by smjg — 2011-01-27T03:37:25Z
There are several bugs whereby one can overwrite immutable data. See issue 2573.
Comment #11 by smjg — 2011-05-10T16:55:58Z
*** Issue 5958 has been marked as a duplicate of this issue. ***