Thread overview | |||||
---|---|---|---|---|---|
|
October 16, 2011 [Issue 6815] New: Char array is turned into string expression during constant folding | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=6815 Summary: Char array is turned into string expression during constant folding Product: D Version: D2 Platform: Other OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: dawg@dawgfoto.de --- Comment #0 from dawg@dawgfoto.de 2011-10-15 20:35:22 PDT --- struct DChars { dchar foo() { return ary[0]; } dchar[] ary; } DChars get() { DChars s; s.ary ~= 'H'; s.ary ~= 'e'; return s; } enum dchars = get().foo(); ---- Which will bark: Error: cannot cast a read-only string literal to mutable in CTFE Cat in constfold.c turns null ~ char into a string expression even though the type of null is not a string but a char array. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 13, 2012 [Issue 6815] Char array is turned into string expression during constant folding | ||||
---|---|---|---|---|
| ||||
Posted in reply to dawg@dawgfoto.de | http://d.puremagic.com/issues/show_bug.cgi?id=6815 Denis <verylonglogin.reg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |verylonglogin.reg@gmail.com --- Comment #1 from Denis <verylonglogin.reg@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: ------- |
February 23, 2012 [Issue 6815] Char array is turned into string expression during constant folding | ||||
---|---|---|---|---|
| ||||
Posted in reply to dawg@dawgfoto.de | http://d.puremagic.com/issues/show_bug.cgi?id=6815 --- Comment #2 from Don <clugdbug@yahoo.com.au> 2012-02-23 02:08:29 PST --- (In reply to comment #1) > Probably the same issue: Nope, completely different. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation