Bug 1185 – assignment failure

Status
RESOLVED
Resolution
INVALID
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2007-04-24T05:10:00Z
Last change time
2015-06-09T05:15:08Z
Assigned to
dvdfrdmn
Creator
sheffmail

Comments

Comment #0 by sheffmail — 2007-04-24T05:10:50Z
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.