Subject: Re: [boost] [type_traits] Variadic function pointer with __fastcall calling convention
From: Stephan T. Lavavej (stl_at_[hidden])
Date: 2013-10-01 21:40:07
I audited VC's <type_traits> for calling convention madness, and I do not believe that custom calling conventions can be applied to old-style varargs. It's been a few months since I looked at this, but VC sometimes looks at a calling convention that shouldn't be there (this is especially true for x64/ARM) and simply pretends that it's an acceptable calling convention.
To figure out all of the criteria for calling conventions, I wrote a templated struct, then attempted to specialize it for all known calling conventions, then removed the ones that triggered errors (due to immediate rejections) or duplicates (due to silent rewrites).
Here is my Matrix Of Doom, transcribed as (mostly) English instead of code:
__cdecl - Always.
__clrcall - _M_CEE defined.
__fastcall - _M_IX86 defined and _M_CEE not defined.
__stdcall - _M_IX86 defined.
__thiscall - _M_IX86 defined. Member functions only.
__vectorcall - VC 2013 or newer. _M_CEE must not be defined. Available for _M_X64. Available for _M_IX86 when _M_IX86_FP is at least 2.
To be resistant to the calling convention switches (/Gd, /Gr, /Gz, /Gv) I always mark specializations for free/member function pointers with a calling convention (__cdecl is always present, at a minimum). The only exception is the old-style variadics, which I do not mark with any explicit calling convention.
It is (quite) possible that there is a bug in my machinery, but so far it seems to be well-behaved in VC 2013 (the only deficiency is that I need to apply it throughout the STL).
From: Boost [mailto:boost-bounces_at_[hidden]] On Behalf Of Edward Diener
Sent: Tuesday, October 01, 2013 6:09 PM
Subject: [boost] [type_traits] Variadic function pointer with __fastcall calling convention
In type_traits/detail/is_function_ptr_tester.hpp there are pointer to
function signatures being tested which have the __fastcall calling
convention and variadic functions. While MSVC accepts this code clang in
Windows, which defines _MSC_VER and _MSC_EXTENSIONS, currently gives an
error. The justification for giving an error is that __fastcall is a
callee stack cleanup calling convention, so it cannot be used for
There is a bug report regarding this in the Bugzilla for llvm at
Comments have been made to me in e-mail and the clang developer's
mailing list that it is a type_traits error to allow this, even for
MSVC-emulation code. Of course we can temporarily fix this for clang on
Windows, possibly with a BOOST_WORKAROUND solution for clang and see
if/how clang eventually addresses the bug report. But I would like some
sort of resolution so that clang on Windows can compile type_traits in
the current Boost trunk.
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk