[Issue 2418] Same-value string (char[]) literals get overwritten (unlike array literals)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 15 00:36:58 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2418





------- Comment #5 from kamm-removethis at incasoftware.de  2008-10-15 02:36 -------
The D spec says "String literals are immutable (read only)." even in D1. So
code like this

char[] a = "ABC";
a[0] = '!';

is illegal (and will segfault on linux!).

Array literals are allocated on the heap (the D spec explicitly says so) and
will thus behave fundamentally different from string literals. 


-- 



More information about the Digitalmars-d-bugs mailing list