The following code compiles successfully but when it runs it generates SIGSEGV:
int main(char[][] args)
{
char[] a = "a";
a[0] = 'b';
}
Comment #1 by afb — 2007-04-24T05:32:56Z
This is by language design, the code is not using COW.
(should use a a.dup, before trying to assign anything)
See http://www.digitalmars.com/d/dcompiler.html#linux :
Differences from Win32 version
* String literals are read-only. Attempting to write to them will cause a segment violation.
Same goes for GDC, see the "writable-strings" settings.
Comment #2 by bugzilla — 2007-04-25T03:28:48Z
Writing to string literals causes undefined behavior.