diff --git a/compiler/src/dmd/expressionsem.d b/compiler/src/dmd/expressionsem.d index 0e5ccf3e8a6..ca2ca23196f 100644 --- a/compiler/src/dmd/expressionsem.d +++ b/compiler/src/dmd/expressionsem.d @@ -12403,12 +12403,10 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (!p1.equivalent(p2)) { - // Deprecation to remain for at least a year, after which this should be - // changed to an error // See https://github.com/dlang/dmd/pull/7332 - deprecation(exp.loc, - "cannot subtract pointers to different types: `%s` and `%s`.", + error(exp.loc, "cannot subtract pointers to different types: `%s` and `%s`.", t1.toChars(), t2.toChars()); + return setError(); } // Need to divide the result by the stride diff --git a/compiler/test/fail_compilation/test11006.d b/compiler/test/fail_compilation/test11006.d index e7257b7c2e3..69b5cb14875 100644 --- a/compiler/test/fail_compilation/test11006.d +++ b/compiler/test/fail_compilation/test11006.d @@ -1,11 +1,15 @@ -/* REQUIRED_ARGS: -main -de - * TEST_OUTPUT: +/* TEST_OUTPUT: --- -fail_compilation/test11006.d(10): Deprecation: cannot subtract pointers to different types: `void*` and `int*`. -fail_compilation/test11006.d(10): while evaluating: `static assert(2L == 2L)` -fail_compilation/test11006.d(11): Deprecation: cannot subtract pointers to different types: `int*` and `void*`. -fail_compilation/test11006.d(11): while evaluating: `static assert(8L == 8L)` +fail_compilation/test11006.d(11): Error: cannot subtract pointers to different types: `void*` and `int*`. +fail_compilation/test11006.d(11): while evaluating: `static assert(2L == 2L)` +fail_compilation/test11006.d(12): Error: cannot subtract pointers to different types: `int*` and `void*`. +fail_compilation/test11006.d(12): while evaluating: `static assert(8L == 8L)` +fail_compilation/test11006.d(15): Error: cannot subtract pointers to different types: `ushort*` and `ubyte*`. --- */ 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; +}