diff --git a/util/misc/no_cfi_icall.h b/util/misc/no_cfi_icall.h index dcd0b9bf..25535b40 100644 --- a/util/misc/no_cfi_icall.h +++ b/util/misc/no_cfi_icall.h @@ -76,6 +76,28 @@ struct FunctorTraits { }; #endif // OS_WIN && ARCH_CPU_X86 +#if __cplusplus >= 201703L +// These specializations match functions which are not explicitly declared +// noexcept. They must only be present at C++17 when noexcept is part of a +// function's type. If they are present earlier, they redefine the +// specializations above. +template +struct FunctorTraits { + template + DISABLE_CFI_ICALL static R Invoke(Function&& function, RunArgs&&... args) { + return std::forward(function)(std::forward(args)...); + } +}; + +template +struct FunctorTraits { + template + DISABLE_CFI_ICALL static R Invoke(Function&& function, RunArgs&&... args) { + return std::forward(function)(std::forward(args)...); + } +}; +#endif + } // namespace //! \brief Disables cfi-icall for calls made through a function pointer.