GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc

Reject variadic functions with callback_only attribute

callback_only attribute handler now rejects variadic functions and updates documentation.

GCC’s callback_only attribute handler has been updated to explicitly reject variadic functions. Previously, the handler and attribute implementation implicitly assumed non-variadic functions, which could lead to undefined behavior. This change adds necessary checks and updates documentation to reflect this restriction, ensuring correct usage of the attribute.

In Details

This commit enhances handle_callback_only_attribute in c-attribs.cc to reject variadic functions. The attribute's design and associated semantics in GCC's internal representation assume non-variadic call targets. The patch adds explicit checks for this condition and updates extend.texi and test cases to document and enforce this limitation, preventing potential runtime issues or compiler internal inconsistencies.

For Context
callback_only attribute
A function attribute that signifies certain restrictions or properties of functions intended to be used as callbacks. The exact implications depend on the context in which it's applied within the compiler.
variadic function
A function that can accept a variable number of arguments, indicated by an ellipsis (...) in its parameter list.
c-attribs.cc
A GCC source file containing the implementation for handling various C language attributes.
extend.texi
A TeXinfo file used by GCC to document compiler extensions, including function attributes and other language features not part of the standard C or C++ languages.
Filed Under: attributevalidationdocumentation