mirror of
https://github.com/dlang/dmd.git
synced 2025-04-25 20:50:41 +03:00
Fix #20330 - Make subtracting pointers of different types an error
This commit is contained in:
parent
b7a3a1942c
commit
8d2fe40f4b
3 changed files with 21 additions and 10 deletions
11
changelog/dmd.deprecation-pointer-subtract.dd
Normal file
11
changelog/dmd.deprecation-pointer-subtract.dd
Normal 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;
|
||||
}
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue