https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87145

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This fixes it.  But is it the best fix?

--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -8056,7 +8056,14 @@ convert_template_argument (tree parm,
    t = canonicalize_type_argument (t, complain);

       if (!type_dependent_expression_p (orig_arg)
-     && !uses_template_parms (t))
+     && !uses_template_parms (t)
+     /* This might trigger calling a conversion function with
+        a value-dependent argument, which could invoke taking
+        the address of a temporary representing the result of
+        the conversion.  */
+     && !(COMPOUND_LITERAL_P (orig_arg)
+          && MAYBE_CLASS_TYPE_P (TREE_TYPE (orig_arg))
+          && value_dependent_expression_p (orig_arg)))
    /* We used to call digest_init here.  However, digest_init
       will report errors, which we don't want when complain
       is zero.  More importantly, digest_init will try too
@@ -8092,7 +8099,7 @@ convert_template_argument (tree parm,
          && TREE_CODE (TREE_TYPE (innertype)) == FUNCTION_TYPE
          && TREE_OPERAND_LENGTH (inner) > 0
               && reject_gcc_builtin (TREE_OPERAND (inner, 0)))
-              return error_mark_node;
+       return error_mark_node;
         }

       if (TREE_CODE (val) == SCOPE_REF)

Reply via email to