Bug 24145 – subtracting pointers with different types is both deprecated and an error

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-09-13T21:54:40Z
Last change time
2024-12-13T19:30:46Z
Keywords
diagnostic
Assigned to
No Owner
Creator
elpenguino+D
Moved to GitHub: dmd#20330 →

Comments

Comment #0 by elpenguino+D — 2023-09-13T21:54:40Z
``` void main() { auto foo = (ushort*).init - (ubyte*).init; } ``` As of DMD 2.105.0, this code prints a deprecation and an error: ``` test.d(2): Deprecation: cannot subtract pointers to different types: `ushort*` and `ubyte*`. test.d(2): Error: incompatible types for ((null) - (null)): 'ushort*' and 'ubyte*' ``` This appears to be the case as far back as 2.078.x. There is a changelog entry for its deprecation in 2.078.0's release, but why was it deprecated when it already didn't compile?
Comment #1 by robert.schadek — 2024-12-13T19:30:46Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20330 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB