|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
D.gnu - [Issue 1766] New: segfault writing to a string variable...
http://d.puremagic.com/issues/show_bug.cgi?id=1766 Summary: segfault writing to a string variable... Product: DGCC aka GDC Version: 0.24 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: glue layer AssignedTo: dvdfrdmn users.sf.net ReportedBy: funisher gmail.com gentoo gdc 0.24, x86_64, no cflags here is a simple test case: void main() { string lala = " "; lala[0] = '1'; } however, reading is fine... void main() { string lala; lala = "-----"; printf("%c %d", lala[0], lala.length); // prints '- 5' } -- Jan 02 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1766 ------- Comment #1 from ddparnell bigpond.com 2008-01-02 19:25 ------- I don't think this is a bug. Its working as I would expect it to. The identifier 'lala' is not a VARIABLE, its a reference to a string literal and literals are in read-only memory on Linux, thus you can't write to it. The segfault is the operating system's reaction to the attempt. Use this instead ... void main() { string lala = " ".dup; // Take a writable copy of the literal. lala[0] = '1'; } -- Jan 02 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1766 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #2 from bugzilla digitalmars.com 2008-01-02 20:57 ------- This is not a bug, string literals are read-only. -- Jan 02 2008
d-bugmail puremagic.com wrote:http://d.puremagic.com/issues/show_bug.cgi?id=1766 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #2 from bugzilla digitalmars.com 2008-01-02 20:57 ------- This is not a bug, string literals are read-only. Jan 03 2008
On Fri, 04 Jan 2008 00:03:13 +0100, Kenny B wrote:d-bugmail puremagic.com wrote:http://d.puremagic.com/issues/show_bug.cgi?id=1766 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #2 from bugzilla digitalmars.com 2008-01-02 20:57 ------- This is not a bug, string literals are read-only. Jan 03 2008
|