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++.