digitalmars.D.bugs - [Issue 24145] New: subtracting pointers with different types is both
- d-bugmail puremagic.com (31/31) Sep 13 2023 https://issues.dlang.org/show_bug.cgi?id=24145
https://issues.dlang.org/show_bug.cgi?id=24145 Issue ID: 24145 Summary: subtracting pointers with different types is both deprecated and an error Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: diagnostic Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: elpenguino+D gmail.com ``` 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? --
Sep 13 2023