[Issue 6504] Regression(2.041): "str" ~ [arr] allows string literal to be modified
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 1 02:21:09 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6504
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |
--- Comment #3 from Don <clugdbug at yahoo.com.au> 2012-02-01 02:21:04 PST ---
(In reply to comment #2)
> 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.
Reopened, because in every other respect, it behaves as an immutable string
literal.
On Linux, the test case causes a segfault -- it's an attempt to modify an
read-only literal.
On Windows, it's a secret global variable. You can even mark it as pure.
I don't think we can afford to have something so simple causing undefined
behaviour.
Fixing this bug isn't a big deal, btw. Now that I've put an isCtfe flag in
array literals, this case can go back to being an ArrayLiteral without hurting
CTFE performance.
--
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