Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8043635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:57:59+00:00 2026-06-05T04:57:59+00:00

First, we have InterlockedExchange64(); http://msdn.microsoft.com/en-us/library/windows/desktop/ms683593%28v=vs.85%29.aspx LONGLONG __cdecl InterlockedExchange64( __inout LONGLONG volatile *Target, __in LONGLONG

  • 0

First, we have InterlockedExchange64();

http://msdn.microsoft.com/en-us/library/windows/desktop/ms683593%28v=vs.85%29.aspx

LONGLONG __cdecl InterlockedExchange64( __inout LONGLONG volatile *Target, __in LONGLONG Value );

Second, we have the compiler intrinsic, _InterlockedExchange64(), note the absence of volatile;

http://msdn.microsoft.com/en-us/library/1s26w950%28v=vs.80%29.aspx

__int64 _InterlockedExchange64( __int64 * Target, __int64 Value );

Next, we have InterlockedExchangePointer() which like InterlockedExchange64(), uses volatile.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms683609%28v=vs.85%29.aspx

PVOID __cdecl InterlockedExchangePointer( __inout  PVOID volatile *Target, __in PVOID Value );

But now we come to the intrinsic for pointer exchange, _InterlockedExchangePointer() and here we see volatile used!

http://msdn.microsoft.com/en-us/library/853x471w.aspx

void * _InterlockedExchangePointer( void * volatile * Target, void * Value );

The underlying instruction is the same in all cases, so what gives? documentation error?

The GCC instrincs don’t mention volatile for exchange, but then they don’t mention it for CAS either! so that doesn’t help.

My view is that a CAS target is volatile, because you can only know at run time if the exchange will occur; but atomic exchange should not be volatile, because the target is always updated (even if it’s value doesn’t change), so the compiler has no uncertainty.

I see also the function for InterlockedIncrement() are volatile, but the instrincs are not. The intrinsics for CAS have volatile for their destinations.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:58:01+00:00Added an answer on June 5, 2026 at 4:58 am

    MSDN is riddled with mostly minor documentation errors (for instance, __readfsdword was marked as kernel only under the VS 2005 docs), what you should really pay attention to is the definition the compiler uses, in this case, the definitions in intrin.h (taken from VS2010 Ultimate SP1):

    __MACHINEI(long _InterlockedExchange(long volatile *, long)) 
    __MACHINEIA64(__int64 _InterlockedExchange64(__int64 volatile *, __int64))
    

    as we can see they are indeed volatile pointers that are required.

    One final thing to note, all your links are the VS 2005 docs (default linked to by google for older intrinsics), so make sure you use the drop down at the top of the page to switch to the latest versions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In order to bring up the menu for a DataGridViewComboBoxCell, I first have to
First I have a Listbox and set the DataSource to a MyObjectCollection MyObjectCollection implements
First I have a PHP file that gets data and file from a HTML
First I have install Mac 10.6.3 on my system now I want to install
I have first: select url from urls where site = '$value' order by url
I have first names stored in one table and last names stored in another.
I have a little problem with some preg_replace functions in PHP. First I have
I have my first ever interview for a Java developer role, specifically RMI, Serverlets
I have my first professional assignment of making a website in which a photographer's
I'm writing an AppWidget where I first have a configure screen where the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.