Summary: [CTFE] UTF-decoding foreach gives wrong index
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Nick Sabalausky <> 2011-08-26 
11:04:43 PDT ---
int[] foo(string str)
    int[] ret;
    foreach(i, dchar c; str)
        ret ~= i;

    return ret;
pragma(msg, foo("Hi"));

Expected: [0,1]
Actual:   [1,2]

Among other likely problems, this causes stripLeft to give the wrong result at

// Should fail, but currently passes:
static assert(stripLeft(" Hello") == "ello");

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to