Fix #20330 - Make subtracting pointers of different types an error

This commit is contained in:
Nicholas Wilson 2024-12-19 05:51:39 +08:00
parent b7a3a1942c
commit 8d2fe40f4b
3 changed files with 21 additions and 10 deletions

View file

@ -0,0 +1,11 @@
An error is now given for subtracting pointers of different types
The following code now gives errors:
```
static assert(cast(void*)8 - cast(int*) 0 == 2L);
static assert(cast(int*) 8 - cast(void*)0 == 8L);
void test()
{
auto foo = (ushort*).init - (ubyte*).init;
}
```