Bug 7898 – [CTFE] std.algorithm:copy fails when used with two arrays
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-04-13T12:38:00Z
Last change time
2012-07-18T20:38:08Z
Keywords
pull
Assigned to
nobody
Creator
xinok
Comments
Comment #0 by xinok — 2012-04-13T12:38:16Z
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()