[Issue 6504] New: Regression(2.041): "str" ~ [arr] allows string literal to be modified

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 16 03:08:20 PDT 2011


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

           Summary: Regression(2.041): "str" ~ [arr] allows string literal
                    to be modified
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: clugdbug at yahoo.com.au


--- Comment #0 from Don <clugdbug at yahoo.com.au> 2011-08-16 03:08:19 PDT ---
for (int i=0; i<3; ++i)
{
    char[] x2 = "xxx" ~ ['c'];
    assert(x2[1] == 'x');
    x2[1] = 'q';
}

The assertion fails the second time through the loop.
What happens, is that "xxx" ~ ['c'] becomes a string literal of value "xxxc"
and type char[]. Thus, it is modifiable.

This code passes on 2.040.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list