Bug 6558 – [CTFE] UTF-decoding foreach gives wrong index (1-indexed)

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-08-26T11:04:00Z
Last change time
2011-09-01T12:12:57Z
Keywords
wrong-code
Assigned to
nobody
Creator
bus_dbugzilla

Comments

Comment #0 by bus_dbugzilla — 2011-08-26T11:04:43Z
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 compile-time: // Should fail, but currently passes: static assert(stripLeft(" Hello") == "ello");
Comment #1 by bus_dbugzilla — 2011-08-26T11:06:52Z
Increasing priority since this is a wrong-code sort of issue.
Comment #2 by bugzilla — 2011-09-01T12:12:57Z