[Issue 10950] New: [CTFE] enum "char[]" not correctly duplicated when used.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 2 04:51:02 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10950
Summary: [CTFE] enum "char[]" not correctly duplicated when
used.
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: monarchdodra at gmail.com
--- Comment #0 from monarchdodra at gmail.com 2013-09-02 04:50:59 PDT ---
//----
enum char[] s = "hello".dup;
void main()
{
auto s1 = s;
auto s2 = s;
assert (s1.ptr != s2.ptr); //Fails;
s1[0] = 'j';
assert(s != "jello"); //Fails
}
//----
This is a pernicious issue, as it effectively modifies what is expected to be
immutable initialization. In particular, it is triggered by the real life code:
enum char[] s = to!(char[])("hello");
enum char[] s = to!(char[])(1);
Where the "to!char[]" is written *specifically* to allow un-aliased write
access.
This behavior was seen on DMD.2.063.2 on windows. I'll test linux later.
--
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