[Issue 6815] Char array is turned into string expression during constant folding

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 13 03:44:05 PST 2012


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


Denis <verylonglogin.reg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |verylonglogin.reg at gmail.com


--- Comment #1 from Denis <verylonglogin.reg at gmail.com> 2012-02-13 14:44:03 MSK ---
Probably the same issue:
---
char[] f() {
    char[] buff = new char[1];
    buff[0] = 0; // works
    buff.ptr[0] = 0; // works
    *(&buff[0]) = 0; // works
    char* t = &buff[0]; *t = 0;   // error
    foreach(ref el; buff) el = 0; // error
    return buff; 
} 

static assert(f() == "\0");
---
Where `error` means: `Error: cannot cast a read-only string literal to mutable
in CTFE`

-- 
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