From: Patrick Palka Date: Tue, 8 Feb 2022 14:11:29 +0000 (-0500) Subject: c++: satisfaction value of type const bool [PR104410] X-Git-Tag: basepoints/gcc-13~1210 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7ff201d85fad11ba6365a5612124b75b385a97bd;p=thirdparty%2Fgcc.git c++: satisfaction value of type const bool [PR104410] Here constant evaluation of the atomic constraint use_func_v sensibly yields an INTEGER_CST of type const bool, but the assert in satisfaction_value expects unqualified bool. So let's just relax the assert to accept cv-qualified bool. PR c++/104410 gcc/cp/ChangeLog: * constraint.cc (satisfaction_value): Relax assert to accept cv-qualified bool. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-pr104410.C: New test. --- diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index b7b9439f34bb..12db7e5cf14e 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -2818,7 +2818,8 @@ satisfaction_value (tree t) return t; gcc_assert (TREE_CODE (t) == INTEGER_CST - && same_type_p (TREE_TYPE (t), boolean_type_node)); + && same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (t), + boolean_type_node)); if (integer_zerop (t)) return boolean_false_node; else diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-pr104410.C b/gcc/testsuite/g++.dg/cpp2a/concepts-pr104410.C new file mode 100644 index 000000000000..dac08e10a0f2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-pr104410.C @@ -0,0 +1,6 @@ +// PR c++/104410 +// { dg-do compile { target c++20 } } + +template constexpr bool use_func_v{}; +template void f() requires use_func_v || true { } +template void f();