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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <[email protected]>:

https://gcc.gnu.org/g:7543dd4654ae17ff44240b037e2a5ef14aca292d

commit r17-1271-g7543dd4654ae17ff44240b037e2a5ef14aca292d
Author: Marek Polacek <[email protected]>
Date:   Wed May 27 13:23:49 2026 -0400

    c++: reference tparm refers to temporary object [PR107124]

    [temp.arg.nontype] tells us that a temporary object is not an acceptable
    template-argument when the corresponding template parameter has reference
    type.  So

      template<const int& CRI> struct B { };
      B<1> b;

    is ill-formed.  In the test below we have a tparm `const int &I` and we
    are trying to deduce `I` from `A<0>`.  Since a temporary would be required
    for the template argument, this should be a deduction failure.

            PR c++/107124

    gcc/cp/ChangeLog:

            * cp-tree.h: Adjust comments to mention
            maybe_build_nontype_implicit_conv instead of
            maybe_convert_nontype_argument.
            * pt.cc (maybe_convert_nontype_argument): Rename to...
            (maybe_build_nontype_implicit_conv): ...this.
            (convert_nontype_argument_maybe_dependent): New, factored
            out of...
            (convert_template_argument): ...here.
            (unify) <case TEMPLATE_PARM_INDEX>: Call
            convert_nontype_argument_maybe_dependent and return unify_invalid
            if it failed.  Don't call strip_typedefs_expr.

    gcc/testsuite/ChangeLog:

            * g++.dg/template/deduce11.C: New test.
            * g++.dg/template/deduce12.C: New test.

    Reviewed-by: Jason Merrill <[email protected]>

Reply via email to