D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3456 - ref foreach over array in CTFE silently fails.
Summary: ref foreach over array in CTFE silently fails.
Status: RESOLVED DUPLICATE of issue 1330
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 major
Assignee: No Owner
URL:
Keywords: diagnostic, wrong-code
Depends on:
Blocks:
 
Reported: 2009-10-30 11:25 UTC by David Simcha
Modified: 2015-06-09 01:26 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Simcha 2009-10-30 11:25:48 UTC
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 Don 2009-11-02 04:58:07 UTC
This is a duplicate of bug 1330.
Comment 2 Don 2009-12-29 00:12:38 UTC

*** This issue has been marked as a duplicate of issue 1330 ***