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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 31 21:27:42 PST 2012


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


Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla at digitalmars.com
         Resolution|                            |INVALID


--- Comment #2 from Walter Bright <bugzilla at digitalmars.com> 2012-01-31 21:27:41 PST ---
I'm going to argue this is not a bug.

While "xxx" is immutable, "xxx"~['c'] is mutable. Otherwise, it would be an
error to use it to initialize x2.

Hence, x2 can modify it. Since x2 is a reference to the initializer, not a copy
of it, the initializer is modified.

The spec says that string literals in the source code are immutable, not
incidental string literals in the compiler that result from other operations.

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