[Issue 6558] New: [CTFE] UTF-decoding foreach gives wrong index (1-indexed)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Aug 26 11:04:46 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6558
Summary: [CTFE] UTF-decoding foreach gives wrong index
(1-indexed)
Product: D
Version: D2
Platform: Other
OS/Version: Windows
Status: NEW
Keywords: wrong-code
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: cbkbbejeap at mailinator.com
--- Comment #0 from Nick Sabalausky <cbkbbejeap at mailinator.com> 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
compile-time:
// Should fail, but currently passes:
static assert(stripLeft(" Hello") == "ello");
--
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