Hi!

The following testcase ICEs in -std=c++26 mode since my r16-4338 C++26
va_start changes.
The problem is that if we have anything non-canonical in a function
type with (...) in C++26 (or C23/C2Y) mode, in this case the R typedef
on return type rather than void, then we try to build TYPE_CANONICAL
for that, but weren't passing in the no_named_args_stdarg_p, so
a type with TYPE_NO_NAMED_ARGS_STDARG_P flag set got TYPE_CANONICAL
with TYPE_NO_NAMED_ARGS_STDARG_P flag cleared and comptypes then
didn't like that as those aren't really compatible types
(...) vs. the C89-ish () which even C++ uses for some type-generic
etc. builtins.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2026-02-05  Jakub Jelinek  <[email protected]>

        PR c++/123977
        * tree.cc (build_function_type): Pass no_named_args_stdarg_p
        as last argument to recursive call.

        * g++.dg/cpp26/stdarg10.C: New test.

--- gcc/tree.cc.jj      2026-02-05 15:53:47.603157855 +0100
+++ gcc/tree.cc 2026-02-05 16:51:48.511416898 +0100
@@ -7780,7 +7780,8 @@ build_function_type (tree value_type, tr
     gcc_assert (TYPE_STRUCTURAL_EQUALITY_P (t));
   else if (any_noncanonical_p)
     TYPE_CANONICAL (t) = build_function_type (TYPE_CANONICAL (value_type),
-                                             canon_argtypes);
+                                             canon_argtypes,
+                                             no_named_args_stdarg_p);
 
   if (!COMPLETE_TYPE_P (t))
     layout_type (t);
--- gcc/testsuite/g++.dg/cpp26/stdarg10.C.jj    2026-02-05 16:56:58.543182179 
+0100
+++ gcc/testsuite/g++.dg/cpp26/stdarg10.C       2026-02-05 16:56:41.575468671 
+0100
@@ -0,0 +1,19 @@
+// PR c++/123977
+// { dg-do compile }
+
+typedef void R;
+struct A {
+  R foo (...) const volatile;
+  void foo ();
+};
+
+template <class T>
+struct B {
+  static void bar () { (T (A::*)) &A::foo; }
+};
+
+void
+baz ()
+{
+  B <R (...) const volatile>::bar;
+}

        Jakub

Reply via email to