Home Dashboard Directory Help
Search

Different intrinsic functions are declared with different calling conventions by Alexey D


Status: 

Closed
 as Fixed Help for as Fixed


2
0
Sign in
to vote
Type: Bug
ID: 584418
Opened: 8/7/2010 5:48:23 PM
Access Restriction: Public
0
Workaround(s)
view
1
User(s) can reproduce this bug

Description

When compiling with calling conventions __stdcall/__fastcall, some intrinsic functions (e.g. _InterlockedIncrement) are declared as __cdecl, some others (e.g. _InterlockedExchange) as __stdcall/__fastcall.

In particular this causes a Boost compilation error.

The following sample suggests __cdecl convention:
http://msdn.microsoft.com/en-us/library/f24ya7ct(VS.71).aspx
Details
Sign in to post a comment.
Posted by Microsoft on 6/2/2011 at 1:36 PM
Thank you for reporting the issue.

A fix for this issue will be part of the next version of Visual Studio.
The correct declarations will be used with these intrinsic declarations.

Thank you,
Mahmoud Saleh
Windows C++ Team
Posted by Microsoft on 9/14/2010 at 3:54 PM
Thanks for the information, we will look into it.
Posted by Alexey D on 9/9/2010 at 5:05 PM
Hello Felix,

Thank you for the reply. I didn't mean that intrin.h is not in line with winbase.h, but that different intrinsics have different calling conventions.

The page
http://msdn.microsoft.com/en-us/library/f24ya7ct(VS.71).aspx
suggests that all these five intrinsics are __cdecl, correct?

Boost uses similar declaration, and the following code fails to compile with __fastcall/__stdcall default settings:

#include "stdafx.h"
#include <intrin.h>
#include <boost/detail/interlocked.hpp>
int main() {}

Compilation errors are like the following:

1>d:\boost\boost_1_44_0\boost\detail\interlocked.hpp(61): error C2373: '_InterlockedCompareExchange' : redefinition; different type modifiers
1>         c:\program files (x86)\microsoft visual studio 10.0\vc\include\intrin.h(214) : see declaration of '_InterlockedCompareExchange'

Do I understand correctly that this is by design that similar intrinsics are declared differently?

Should Boost's declarations for _InterlockedCompareExchange, _InterlockedExchange, _InterlockedExchangeAdd just skip explicit calling convention?

If so, will it be compatible with previous versions of VS?

Best regards,

Alex
Posted by Microsoft on 9/8/2010 at 6:36 PM
Hello Alexey D,
I have looked into the possible mismatch in intrin.h but found it to be in line with winbase.h. The functions are behaving as intended. The increment and decrement do have the enforced cdecl calls, while the other functions default to the compiler's switch (stddecl, fastdecl).

If you could share more information regarding the build error, there could be other factors involved.

Thanks

Felix
Posted by Microsoft on 8/8/2010 at 10:51 PM
Thank you for reporting the issue.
We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution.These specialized experts will follow-up with your issue.
Posted by Microsoft on 8/8/2010 at 4:03 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.