Long literal not allowed as array index on x86

This commit is contained in:
Nick Treleaven 2024-03-25 15:06:56 +00:00
parent c63bb20c83
commit 5e74894ecd

View file

@ -3,7 +3,7 @@ REQUIRED_ARGS: -de
TEST_OUTPUT:
---
fail_compilation/foreach_index_overflow.d(19): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
fail_compilation/foreach_index_overflow.d(21): Deprecation: foreach: loop index implicitly converted from `size_t` to `uint`
fail_compilation/foreach_index_overflow.d(21): Deprecation: foreach: loop index implicitly converted from `size_t` to `ushort`
fail_compilation/foreach_index_overflow.d(24): Deprecation: foreach: loop index implicitly converted from `size_t` to `ubyte`
fail_compilation/foreach_index_overflow.d(26): Deprecation: foreach: loop index implicitly converted from `size_t` to `byte`
---
@ -17,8 +17,8 @@ void main()
int[] arr;
foreach (int index, element; arr[0 .. 0x8000_0000]) {} // OK
foreach (int index, element; arr[0 .. 0x8000_0001]) {} // error
foreach (uint index, element; arr[0 .. 0x1_0000_0000]) {} // OK
foreach (uint index, element; arr[0 .. 0x1_0000_0001]) {} // error
foreach (ushort index, element; arr[0 .. 0x1_0000]) {} // OK
foreach (ushort index, element; arr[0 .. 0x1_0001]) {} // error
int[257] data;
foreach (ubyte i, x; data[]) {} // error