April 16, 2011 [Issue 5846] New: String literals can be assigned to static char arrays without .dup | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5846 Summary: String literals can be assigned to static char arrays without .dup Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: andrej.mitrovich@gmail.com --- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-04-16 10:36:37 PDT --- Isn't the following invalid code? char[3] value = "abc"; -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 18, 2011 [Issue 5846] String literals can be assigned to static char arrays without .dup | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=5846 Steven Schveighoffer <schveiguy@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |schveiguy@yahoo.com Resolution| |INVALID --- Comment #1 from Steven Schveighoffer <schveiguy@yahoo.com> 2011-04-18 06:07:35 PDT --- No. It is valid. value is allocated on the stack, or in TLS depending on where you declared it. Assigning it to the literal does not make it reference the actual literal data, it just copies the data into the value. In other words, changing an element of value does not change the immutable memory that the literal refers to. -- 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