{
tree type = tsubst (TREE_TYPE (t), args, complain, in_decl);
tree op0 = tsubst_copy (TREE_OPERAND (t, 0), args, complain, in_decl);
- return cp_build_bit_cast (EXPR_LOCATION (t), type, op0, complain);
+ r = build_min (BIT_CAST_EXPR, type, op0);
+ SET_EXPR_LOCATION (r, EXPR_LOCATION (t));
+ return r;
}
case SIZEOF_EXPR:
RETURN (r);
}
+ case BIT_CAST_EXPR:
+ {
+ tree type = tsubst (TREE_TYPE (t), args, complain, in_decl);
+ tree op0 = RECUR (TREE_OPERAND (t, 0));
+ RETURN (cp_build_bit_cast (EXPR_LOCATION (t), type, op0, complain));
+ }
+
case POSTDECREMENT_EXPR:
case POSTINCREMENT_EXPR:
op1 = tsubst_non_call_postfix_expression (TREE_OPERAND (t, 0),
--- /dev/null
+// PR c++/98329
+// { dg-do compile { target c++20 } }
+
+template <typename To, typename From>
+constexpr To
+foo (const From &from)
+{
+ return __builtin_bit_cast (To, &from);
+}
+
+template <typename To, typename From>
+constexpr To
+bar (const From &from)
+{
+ return __builtin_bit_cast (To, *from);
+}
+
+template <typename To, typename From>
+constexpr To
+baz (const From &from)
+{
+ return __builtin_bit_cast (To, **from);
+}
+
+template <typename To, typename From>
+constexpr To
+qux (const From &from)
+{
+ return __builtin_bit_cast (To, -from);
+}
+
+void
+test ()
+{
+ int i = 0;
+ int *j = &i;
+ int **k = &j;
+ foo <char *> (i);
+ bar <int> (j);
+ baz <int> (k);
+ qux <int> (i);
+}