gnu/gcc.git/37738f0422aa4d70ac5a71bd82b6c257a9309bde c++: Fix up recent regression in convert_nontype_argument for C++1[14] [PR124173]
The following testcase is rejected since my recent convert_nontype_argument
change, but only in C++11/14 modes.
The problem is that C++17 says that all NTTPs should be converted constant
expressions, but C++11 only said that for integral and enumeration ones and
something that applied to the decltype(nullptr) case was
- a constant expression that evaluates to a null pointer value
The problem is that for NULLPTR_TYPE_P for C++11/14, we just never called
maybe_constant_value, so obviously just making sure it is integer_zerop and
without tf_error returning NULL_TREE otherwise changes behavior on valid
programs, we really need to constant evaluate it first.
The following patch fixes that.
I'm afraid I actually don't know what exactly C++14 specifies, whether I've
grabbed a pre-C++14 or post-C++14 draft, which looked like the C++17
wording. So, if C++14 needs something different, we'll need a further
change, but this at least fixes the regression.
2026-02-22 Jakub Jelinek <jakub@redhat.com>
PR c++/124173
* pt.cc (convert_nontype_argument): For C++11/C++14 handle
NULLPTR_TYPE_P non-type arguments like TYPE_PTR_P.
* g++.dg/cpp0x/pr124173.C: New test.
2 files changed