Skip to content

Commit

Permalink
Make subtracting pointers of different types an error
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilsonator committed Dec 18, 2024
1 parent b7a3a19 commit ed9dbfb
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions compiler/src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ed9dbfb

Please sign in to comment.