]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: fix build error after forward_scope_exit changes
authorAndrew Burgess <aburgess@redhat.com>
Tue, 9 Dec 2025 10:34:11 +0000 (10:34 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Tue, 9 Dec 2025 10:34:11 +0000 (10:34 +0000)
After commit:

  commit 43db8f70d86b2492b79f59342187b919fd58b3dd
  Date:   Thu Oct 23 16:34:20 2025 +0100

      gdbsupport: remove undefined behaviour from (forward_)scope_exit

A build failure was reported[1] when using clang++.  The failure looks
like this:

    CXX    aarch64-fbsd-tdep.o
  In file included from /tmp/src/binutils-gdb/gdb/aarch64-fbsd-tdep.c:22:
  In file included from /tmp/src/binutils-gdb/gdb/gdbarch.h:28:
  In file included from /tmp/src/binutils-gdb/gdb/infrun.h:21:
  In file included from /tmp/src/binutils-gdb/gdb/gdbthread.h:35:
  /tmp/src/binutils-gdb/gdb/../gdbsupport/forward-scope-exit.h:112:20: error: too many template arguments
  for class template 'forward_scope_exit_policy'
    112 |         = scope_exit_base<forward_scope_exit_policy<Function,
        |                           ^
    113 |                                                     function, Res, Args...>>;
        |                                                                    ~~~~~~~~
  /tmp/src/binutils-gdb/gdb/../gdbsupport/forward-scope-exit.h:82:8: note: template is declared here
     81 | template<typename Function, Function *function, typename Signature>
        | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     82 | struct forward_scope_exit_policy;
        |        ^

The problem is that the forward_scope_exit_policy class expects 3
template arguments, but in forward-scope-exit.h we say:

  template<typename Function, Function *function,
    typename Res, typename... Args>
  using forward_scope_exit
   = scope_exit_base<forward_scope_exit_policy<Function,
       function, Res, Args...>>;

Which passes 4 template arguments.  Fix this by changing the above
'using' like too:

  template<typename Function, Function *function, typename Signature>
  using forward_scope_exit
   = scope_exit_base<forward_scope_exit_policy<Function, function,
       Signature>>;

This now compiles with clang++.

gdbsupport/forward-scope-exit.h

index fd93374afc97f5cbd7729fb5be1cedac3b7e55fe..35ef521de623e7cc55b92d465b18660586d72c24 100644 (file)
@@ -106,11 +106,10 @@ private:
     m_bind_function;
 };
 
-template<typename Function, Function *function,
-        typename Res, typename... Args>
+template<typename Function, Function *function, typename Signature>
 using forward_scope_exit
-       = scope_exit_base<forward_scope_exit_policy<Function,
-                                                   function, Res, Args...>>;
+       = scope_exit_base<forward_scope_exit_policy<Function, function,
+                                                   Signature>>;
 
 } /* namespace detail */