[gcc r11-9544] c++: satisfaction value of type const bool [PR104410]
Patrick Palka
ppalka@gcc.gnu.org
Tue Feb 8 17:33:25 GMT 2022
https://gcc.gnu.org/g:411db3b4cf8655ecb5b7d666318546c73f2d156b
commit r11-9544-g411db3b4cf8655ecb5b7d666318546c73f2d156b
Author: Patrick Palka <ppalka@redhat.com>
Date: Tue Feb 8 09:11:29 2022 -0500
c++: satisfaction value of type const bool [PR104410]
Here constant evaluation of the atomic constraint use_func_v<T>
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.
(cherry picked from commit 7ff201d85fad11ba6365a5612124b75b385a97bd)
Diff:
---
gcc/cp/constraint.cc | 3 ++-
gcc/testsuite/g++.dg/cpp2a/concepts-pr104410.C | 6 ++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 5bdf6071a0f..1519d0f1041 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -2867,7 +2867,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 00000000000..dac08e10a0f
--- /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<class T> constexpr bool use_func_v{};
+template<class T> void f() requires use_func_v<T> || true { }
+template void f<int>();
More information about the Gcc-cvs
mailing list