| 1 |
/* |
| 2 |
REQUIRED_ARGS: -de -m64 |
| 3 |
TEST_OUTPUT: |
| 4 |
--- |
| 5 |
fail_compilation/foreach_index_overflow.d(19): Deprecation: foreach: loop index implicitly converted from `size_t` to `int` |
| 6 |
fail_compilation/foreach_index_overflow.d(21): Deprecation: foreach: loop index implicitly converted from `size_t` to `ushort` |
| 7 |
fail_compilation/foreach_index_overflow.d(24): Deprecation: foreach: loop index implicitly converted from `size_t` to `ubyte` |
| 8 |
fail_compilation/foreach_index_overflow.d(26): Deprecation: foreach: loop index implicitly converted from `size_t` to `byte` |
| 9 |
--- |
| 10 |
*/ |
| 11 |
|
| 12 |
void main() |
| 13 |
{ |
| 14 |
enum { red, green, blue } |
| 15 |
foreach (int i, color; [red, green, blue]) {} // OK |
| 16 |
|
| 17 |
int[] arr; |
| 18 |
foreach (int index, element; arr[0 .. 0x8000_0000]) {} // OK |
| 19 |
foreach (int index, element; arr[0 .. 0x8000_0001]) {} // error |
| 20 |
foreach (ushort index, element; arr[0 .. 0x1_0000]) {} // OK |
| 21 |
foreach (ushort index, element; arr[0 .. 0x1_0001]) {} // error |
| 22 |
|
| 23 |
int[257] data; |
| 24 |
foreach (ubyte i, x; data[]) {} // error |
| 25 |
foreach (ubyte i, x; data[0..256]) {} // OK |
| 26 |
foreach (byte i, x; data[0..0x81]) {} // error |
| 27 |
foreach (byte i, x; data[0..0x80]) {} // OK |
| 28 |
} |