Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Adding an exception for implementers

...

Code Block
bgColor#ccccff
langcpp
#include <type_traits>
 
template <typename Arg, typename... Ts, typename std::enable_if<std::is_integral<Arg>::value>::type * = nullptr>
int Add(Arg I, Arg J, Ts... All) {
  int Values[] = { J, All... };
  int R = I;
  for (auto V : Values) {
    R += V;
  }
  return R;
}

Exceptions

DCL50-CPP-EX1: It is permissible to define a C-style variadic function if that function also has external, C language linkage. For instance, the function may be a definition used in a C library API that is implemented in C++.

Risk Assessment

Incorrectly using a variadic function can result in abnormal program termination, unintended information disclosure, or execution of arbitrary code.

...