]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Handle EXACT_DIV_EXPR as printing `/` [PR119567]
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Mon, 20 Apr 2026 05:05:33 +0000 (22:05 -0700)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Sun, 3 May 2026 21:44:06 +0000 (14:44 -0700)
Before r8-4233-g6ff16d19d26a41, we would print EXACT_DIV_EXPR as `(ceiling /)`
which is wrong. Now we print it as `unknown operator` which is also wrong.
Printing it as `/` is correct here since it is the similar to `FLOOR_DIV_EXPR`
except it is undefined behavior if it is not exact (so floor is fine :)).
This shows up when printing out the reason why the following is not a contexpr:
constexpr int (*p1)[0] = 0, (*p2)[0] = 0;
constexpr int k2 = p2 - p1;

Bootstrapped and tested on x86_64-linux-gnu.

PR c++/119567
gcc/cp/ChangeLog:

* error.cc (dump_expr): Treat EXACT_DIV_EXPR the same as FLOOR_DIV_EXPR.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/cp/error.cc

index 2ea9d1a7bcd64cb88fb6ec40a49d34c04cd83d7c..5f4cb477230762228fd2b75ff46571cf49e5804e 100644 (file)
@@ -2629,7 +2629,6 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
     case EQ_EXPR:
     case NE_EXPR:
     case SPACESHIP_EXPR:
-    case EXACT_DIV_EXPR:
       dump_binary_op (pp, OVL_OP_INFO (false, TREE_CODE (t))->name, t, flags);
       break;
 
@@ -2637,6 +2636,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
     case FLOOR_DIV_EXPR:
     case ROUND_DIV_EXPR:
     case RDIV_EXPR:
+    case EXACT_DIV_EXPR:
       dump_binary_op (pp, "/", t, flags);
       break;