On 10/1/2013 9:40 PM, Stephan T. Lavavej wrote:
I audited VC's
for calling convention madness, and I do not believe that custom calling conventions can be applied to old-style varargs.
Nonetheless VC++ ( 8, 9, 10, and 11 ) does not produce a compiler error when a __stdcall or __fastcall calling convention is used in a pointer to function taking old-style varags. Do you see this as an ongoing bug in VC++ ? If so Boost type_traits should not support it AFAICS.
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.
Understood.
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.
The list is appreciated. But were old-style varargs included in your tests ?
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).
I have not tried VC in VS2013, but the matter should be cleared up so that VC++ at least does not at accept the __fastcall calling convention with old-style varags if what you say in the first line of your reply is true.
STL
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Edward Diener Sent: Tuesday, October 01, 2013 6:09 PM To: boost@lists.boost.org 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 variadic functions.
There is a bug report regarding this in the Bugzilla for llvm at http://llvm.org/bugs/show_bug.cgi?id=12535.
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
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost