Thread overview
[Issue 1185] New: assignment failure
Apr 24, 2007
d-bugmail
Apr 24, 2007
d-bugmail
Apr 25, 2007
d-bugmail
April 24, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1185

           Summary: assignment failure
           Product: DGCC aka GDC
           Version: 0.23
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: glue layer
        AssignedTo: dvdfrdmn@users.sf.net
        ReportedBy: sheffmail@mail.ru


The following code compiles successfully but when it runs it generates SIGSEGV:

int main(char[][] args)
{
 char[] a = "a";
 a[0] = 'b';
}


-- 

April 24, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1185





------- Comment #1 from afb@algonet.se  2007-04-24 05:32 -------
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.


-- 

April 25, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1185


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




------- Comment #2 from bugzilla@digitalmars.com  2007-04-25 03:28 -------
Writing to string literals causes undefined behavior.


--