https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122605
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=105951
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2025-11-08
Target Milestone|--- |16.0
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The build_call_nary call here does:
```
tree exp = build_call_nary (type, tcall,
2 + is_atomic, ptr, arg,
is_atomic
? gimple_call_arg (call, 3)
: integer_zero_node);
```
But nargs here is sometimes one more than expected.
The obvious change would be:
```
tree exp;
if (is_atomic)
exp = build_call_nary (type, tcall,
3, ptr, arg, gimple_call_arg (call, 3));
else
exp = build_call_nary (type, tcall,
2, ptr, arg);
```
This happens a few times in builtins.c when expanding the internal functions
for atomic.
Before we allowed nargs be less than the args passed but there is no reason to
allow that. As shown the above fix is cleaner really and makes it more obvious
what is going on.