[cfe-dev] clang for Windows problem in Boost.TypeTraits

Óscar Fuentes ofv at wanadoo.es
Mon Sep 30 10:29:33 PDT 2013


Edward Diener <eldlistmailingz at tropicsoft.com>
writes:

> In Boost.TypeTraits this header file line:
>
>  template <class R >
>  yes_type is_function_ptr_tester(R (__fastcall*)( ...));
>
> gets an error message from clang in Windows of:
>
> ..\..\..\boost/type_traits/detail/is_function_ptr_tester.hpp:52:36:
> error: variadic function cannot use fastcall calling convention
>
> I could not find anything in the C++11 standard about variadic
> functions and calling conventions. Is this a "bug" with clang under
> Windows or should Boost.TypeTraits not try to allow __fastcall in this
> situation when compiling with clang under Windows ?
>
> This occurs in this place in Boost.TypeTraits with clang in Windows
> because _MSC_VER is defined and the code is acceptable with VC++.

Some calling conventions are hardly usable with variable number of
arguments. __fastcall, for instance requires that the called function
clears the stack, which poses obvious difficulties. I doubt that VC++
supports the necessary wizardly for *helping* the *programmer* to
properly do that. (Actually, the user would need to implement its own
calling convention on top of __fastcall and then use some compiler
intrinsics for accessing the parameters and cleaning up the stack.)

OTOH it is possible that the the function is never called or even that
no such function exists at all (a device on template metaprogramming,
for instance.)

So, IMO, VC++ might be too lax here while Clang++ is too strict. If
Clang++ is rejecting code that just declares a __fastcall variadic
function and such declaration is useful, I'll file a bug report.




More information about the cfe-dev mailing list