+2020-02-26 Marek Polacek <polacek@redhat.com>
+
+ PR c++/93862 - ICE with static_cast when converting from int[].
+ * call.c (reference_compatible_p): No longer static.
+ * cp-tree.h (reference_compatible_p): Declare.
+ * typeck.c (build_static_cast_1): Use reference_compatible_p instead
+ of reference_related_p.
+
2020-02-26 Marek Polacek <polacek@redhat.com>
PR c++/93803 - ICE with constexpr init and [[no_unique_address]].
conversion **, tree, tree, int, struct rejection_reason *, int);
static tree source_type (conversion *);
static void add_warning (struct z_candidate *, struct z_candidate *);
-static bool reference_compatible_p (tree, tree);
static conversion *direct_reference_binding (tree, conversion *);
static bool promoted_arithmetic_type_p (tree);
static conversion *conditional_conversion (tree, tree, tsubst_flags_t);
/* Returns nonzero if T1 is reference-compatible with T2. */
-static bool
+bool
reference_compatible_p (tree t1, tree t2)
{
/* [dcl.init.ref]
extern bool type_has_extended_temps (tree);
extern tree strip_top_quals (tree);
extern bool reference_related_p (tree, tree);
+extern bool reference_compatible_p (tree, tree);
extern int remaining_arguments (tree);
extern tree perform_implicit_conversion (tree, tree, tsubst_flags_t);
extern tree perform_implicit_conversion_flags (tree, tree, tsubst_flags_t, int);
if (TYPE_REF_P (type)
&& TYPE_REF_IS_RVALUE (type)
&& (clk = real_lvalue_p (expr))
- && reference_related_p (TREE_TYPE (type), intype)
+ && reference_compatible_p (TREE_TYPE (type), intype)
&& (c_cast_p || at_least_as_qualified_p (TREE_TYPE (type), intype)))
{
if (processing_template_decl)
+2020-02-26 Marek Polacek <polacek@redhat.com>
+
+ PR c++/93862 - ICE with static_cast when converting from int[].
+ * g++.dg/cpp0x/rv-cast7.C: New test.
+
2020-02-26 Marek Polacek <polacek@redhat.com>
DR 1423, Convertibility of nullptr to bool.
--- /dev/null
+// PR c++/93862 - ICE with static_cast when converting from int[].
+// { dg-do compile { target c++11 } }
+
+int(&&intu_rvref)[]{1,2,3,4};
+int(&int4_lvref)[4] = static_cast<int(&)[4]>(intu_rvref); // { dg-error "invalid .static_cast." }
+int(&&int4_rvref)[4] = static_cast<int(&&)[4]>(intu_rvref); // { dg-error "invalid .static_cast." }