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

Edward Diener eldlistmailingz at tropicsoft.com
Mon Sep 30 17:12:34 PDT 2013


On 9/30/2013 1:29 PM, Óscar Fuentes wrote:
> 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.)

The declaration is being used in template metaprogramming so it is being 
invoked at compile time to test whether some compile-time expression is 
a function pointer. It is being implemented for clang, as well VC++ 
compatible compilers on Windows, because _MSC_EXTENSIONS is defined in 
the clang implementation for Windows.

>
> 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.

I can file the bug report as long as it has been ascertained as a clang 
bug. OTOH if you're filing the bug report might have more weight in 
getting it fixed, please go ahead and do so.

I am working to get clang in Windows to be able to compile Boost headers 
using the Boost Build clang toolset. So you may be hearing from me on 
this mailing list with further issues.

Thanks for your help.




More information about the cfe-dev mailing list