[Bug c++/97420] [9/10/11/12 Regression] NTTP function reference cannot bind to noexcept function
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jul 13 14:03:07 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97420
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:bbad9d7cfdb8dd8e28589160120546a61adeeedf
commit r11-8726-gbbad9d7cfdb8dd8e28589160120546a61adeeedf
Author: Patrick Palka <ppalka@redhat.com>
Date: Wed May 26 08:35:31 2021 -0400
c++: Fix reference NTTP binding to noexcept fn [PR97420]
Here, in C++17 mode, convert_nontype_argument_function is rejecting
binding a non-noexcept function reference template parameter to a
noexcept function (encoded as the template argument '*(int (&) (int)) &f').
The first roadblock to making this work is that the argument is wrapped
an an implicit INDIRECT_REF, so we need to unwrap it before calling
strip_fnptr_conv.
The second roadblock is that the NOP_EXPR cast converts from a function
pointer type to a reference type while simultaneously removing the
noexcept qualification, and fnptr_conv_p doesn't consider this cast to
be a function pointer conversion. This patch fixes this by making
fnptr_conv_p treat REFERENCE_TYPEs and POINTER_TYPEs interchangeably.
Finally, in passing, this patch also simplifies noexcept_conv_p by
removing a bunch of redundant checks already performed by its only
caller fnptr_conv_p.
PR c++/97420
gcc/cp/ChangeLog:
* cvt.c (noexcept_conv_p): Remove redundant checks and simplify.
(fnptr_conv_p): Don't call non_reference. Use INDIRECT_TYPE_P
instead of TYPE_PTR_P.
* pt.c (convert_nontype_argument_function): Look through
implicit INDIRECT_REFs before calling strip_fnptr_conv.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/noexcept68.C: New test.
(cherry picked from commit b4329e3dd6fb7c78948fcf9d2f5b9d873deec284)
More information about the Gcc-bugs
mailing list