[Issue 3456] New: ref foreach over array in CTFE silently fails.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 30 11:25:48 PDT 2009


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

           Summary: ref foreach over array in CTFE silently fails.
           Product: D
           Version: 2.035
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic, wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: dsimcha at yahoo.com


--- Comment #0 from David Simcha <dsimcha at yahoo.com> 2009-10-30 11:25:48 PDT ---
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.

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