Bug 5493 – Able to overwrite immutable data by passing through ref function parameter

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P5
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-01-26T12:52:00Z
Last change time
2012-02-12T09:17:10Z
Keywords
accepts-invalid, patch
Assigned to
bugzilla
Creator
robert.welin
Blocks
2573

Comments

Comment #0 by robert.welin — 2011-01-26T12:52:31Z
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. ***
Comment #12 by yebblies — 2011-06-12T00:50:41Z
Comment #13 by schveiguy — 2011-07-12T13:05:59Z
*** Issue 6298 has been marked as a duplicate of this issue. ***
Comment #14 by k.hara.pg — 2011-12-12T22:09:52Z
Comment #15 by bugzilla — 2012-01-16T10:38:11Z
Comment #16 by yebblies — 2012-02-12T09:17:10Z
*** Issue 7486 has been marked as a duplicate of this issue. ***