[PATCH] D13446: [PATCH] Add checker discouraging definition of variadic function definitions in C++

Joerg Sonnenberger via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 6 13:12:02 PDT 2015


On Mon, Oct 05, 2015 at 07:36:08PM +0000, Aaron Ballman via cfe-commits wrote:
> C-style variadic functions (using an ellipsis) can be dangerous in C++
> due to the inherit lack of type safety with argument passing. Better
> alternatives exist, such as function currying (like STL stream objects
> use), or function parameter packs. This patch adds a checker to
> diagnose definitions of variadic functions in C++ code, but still
> allows variadic function declarations, as those can be safely used to
> good effect for SFINAE patterns.

I would restrict this a bit to exclude function definitions with C
linkage. If you have such a ABI requirement, you normally can't replace
it with any of the alternatives.

Joerg


More information about the cfe-commits mailing list