]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: add fixed test [PR106957]
authorMarek Polacek <polacek@redhat.com>
Thu, 28 May 2026 16:18:29 +0000 (12:18 -0400)
committerMarek Polacek <polacek@redhat.com>
Thu, 28 May 2026 16:19:07 +0000 (12:19 -0400)
Fixed by r16-8015:
c++: error routines re-entered with uneval lambda [PR124397]

PR c++/106957

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/lambda-uneval32.C: New test.

gcc/testsuite/g++.dg/cpp2a/lambda-uneval32.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-uneval32.C b/gcc/testsuite/g++.dg/cpp2a/lambda-uneval32.C
new file mode 100644 (file)
index 0000000..6398089
--- /dev/null
@@ -0,0 +1,25 @@
+// PR c++/106957
+// { dg-do compile { target c++20 } }
+
+template<bool B>
+struct bool_constant {
+  static constexpr bool value = B;
+  constexpr operator bool() const { return value; }
+};
+
+using true_type = bool_constant<true>;
+using false_type = bool_constant<false>;
+
+constexpr auto f = [](int){}; // { dg-error "invalid conversion" }
+
+template<typename T>
+auto canCallFOn(T) -> decltype([]{ f(T{}); }(), true_type{}); // { dg-error "no match|invalid conversion" }
+
+constexpr false_type canCallFOn(...) {
+    return {};
+}
+
+int main() {
+    static_assert(!canCallFOn(1)); // { dg-error "" }
+    static_assert(!canCallFOn("")); // { dg-error "" }
+}