Bug 3456 – ref foreach over array in CTFE silently fails.

Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2009-10-30T11:25:00Z
Last change time
2015-06-09T01:26:55Z
Keywords
diagnostic, wrong-code
Assigned to
nobody
Creator
dsimcha

Comments

Comment #0 by dsimcha — 2009-10-30T11:25:48Z
Test program: import std.stdio; char[] ctfeFun() { char[] stuff = "This is clearly a bug.".dup; foreach(ref c; stuff) { c = 'X'; } return stuff; } const compileTimeResult = ctfeFun(); void main() { writeln("Compile time: ", compileTimeResult); writeln("Run time: ", ctfeFun()); } Output: Compile time: This is clearly a bug. Run time: XXXXXXXXXXXXXXXXXXXXXX Marking as severe because, IMHO, anything that silently results in subtly defective code being generated is pretty serious. If this can't be easily fixed, then it should be an error.
Comment #1 by clugdbug — 2009-11-02T04:58:07Z
This is a duplicate of bug 1330.
Comment #2 by clugdbug — 2009-12-29T00:12:38Z
*** This issue has been marked as a duplicate of issue 1330 ***