https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127464
--- Comment #6 from Drea Pinski <pinskia at gcc dot gnu.org> ---
There is code that is supposed to handle this case but after the loop it does
nothing:
```
/* We have to use the function type for validation, as
DECL_ARGUMENTS returns NULL at this point. */
int callback_fn_idx = TREE_INT_CST_LOW (val);
tree decl_type_args = TYPE_ARG_TYPES (decl_type);
tree it;
for (it = decl_type_args; it != NULL_TREE; it = TREE_CHAIN (it))
if (it == void_list_node)
break;
if (callback_fn_idx == CB_UNKNOWN_POS)
{
warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wattributes,
"callback function position cannot be marked as unknown");
*no_add_attrs = true;
return NULL_TREE;
}
--callback_fn_idx;
/* Search for the type of the callback function in parameters of the original
function. We know it's there because it's been validated by
positional_argument. */
tree cfn = chain_index (callback_fn_idx, decl_type_args);
gcc_checking_assert (cfn != NULL_TREE);
```
Notice empty loop iterating on decl_type_args but then does nothing.
Also:
if (stdarg_p (decl_type))
{
warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wattributes,
"%qE attribute cannot be used on variadic functions", name);
*no_add_attrs = true;
return NULL_TREE;
}
is checked twice :).
Also this function is NOT a stdarg_p but an odd one.