[clang] [clang][ExprConst] Add diagnostics for invalid binary arithmetic (PR #118475)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 3 11:01:42 PST 2024


================
@@ -91,11 +91,15 @@ def note_constexpr_pointer_subtraction_zero_size : Note<
   "subtraction of pointers to type %0 of zero size">;
 def note_constexpr_pointer_comparison_unspecified : Note<
   "comparison between '%0' and '%1' has unspecified value">;
+def note_constexpr_pointer_arith_unspecified : Note<
+  "arithmetic involving '%0' and '%1' has unspecified value">;
 def note_constexpr_pointer_constant_comparison : Note<
   "comparison of numeric address '%0' with pointer '%1' can only be performed "
   "at runtime">;
 def note_constexpr_literal_comparison : Note<
   "comparison of addresses of literals has unspecified value">;
+def note_constexpr_literal_arith : Note<
+  "arithmetic on addresses of literals has unspecified value">;
----------------
zygoloid wrote:

```suggestion
def note_constexpr_literal_comparison : Note<
  "comparison of addresses of potentially overlapping literals has unspecified value">;
def note_constexpr_literal_arith : Note<
  "arithmetic on addresses of potentially overlapping literals has unspecified value">;
```

https://github.com/llvm/llvm-project/pull/118475


More information about the cfe-commits mailing list