Thread overview
[Issue 6558] New: [CTFE] UTF-decoding foreach gives wrong index (1-indexed)
Aug 26, 2011
Nick Sabalausky
Aug 26, 2011
Nick Sabalausky
Sep 01, 2011
Walter Bright
August 26, 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@puremagic.com
        ReportedBy: cbkbbejeap@mailinator.com


--- Comment #0 from Nick Sabalausky <cbkbbejeap@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: -------
August 26, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6558


Nick Sabalausky <cbkbbejeap@mailinator.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |major


--- Comment #1 from Nick Sabalausky <cbkbbejeap@mailinator.com> 2011-08-26 11:06:52 PDT ---
Increasing priority since this is a wrong-code sort of issue.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6558


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2011-09-01 12:12:57 PDT ---
https://github.com/D-Programming-Language/dmd/commit/43fc4a3cdd48a3109a98e8c78de2f1c2bfe28842

https://github.com/D-Programming-Language/dmd/commit/fba66450c1492dcb2174886c95b35f4672cab6b3

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------