Bug 8773 – [CTFE] foreach ref element doesn't work well at compile time.

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-10-07T01:18:00Z
Last change time
2012-10-08T07:41:36Z
Assigned to
nobody
Creator
zan77137

Comments

Comment #0 by zan77137 — 2012-10-07T01:18:56Z
This code doesn't work well: -------------------------------------- import std.stdio; void foo(ref string[] data) { foreach (ref e; data) { e = e ~ "!"; } } string[] bar(string[] data) { foo(data); return data; } void main() { enum data = ["a", "bcde", "abcde"]; enum resCt = bar(data); auto resRt = bar(data); writeln(resCt); // NG: ["a", "bcde", "abcde"] writeln(resRt); // OK: ["a!", "bcde!", "abcde!"] assert(resCt == resRt); // NG } -------------------------------------
Comment #1 by clugdbug — 2012-10-08T06:02:34Z
Duplicate of bug 7658?
Comment #2 by zan77137 — 2012-10-08T07:41:36Z
Hm... By all appearance it looks like it. *** This issue has been marked as a duplicate of issue 7658 ***