[Issue 7898] New: copy in std.algorithm fails in CTFE when used with two arrays

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 13 12:37:30 PDT 2012


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

           Summary: copy in std.algorithm fails in CTFE when used with two
                    arrays
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: xinok at live.com


--- Comment #0 from Xinok <xinok at live.com> 2012-04-13 12:38:16 PDT ---
The following code fails in DMD 2.059 but not 2.058. It fails on the pointer
arithmetic, and there's no separate pathway for CTFE.

int test()
{
    import std.algorithm;
    int[] arr1 = [10, 20, 30, 40, 50];
    int[] arr2 = arr1.dup;
    copy(arr1, arr2);
    return 35;
}

void main()
{
    enum v = test();
}

C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(5433): Error:
cast(int*)source and cast(int*)target point to independent memory blocks and
cannot be compared at compile time
main.d(15):        called from here: copy(arr1,arr2)
main.d(21):        called from here: test()

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