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

  • SEARCH
  • Home
  • 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 6593349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:40:15+00:00 2026-05-25T17:40:15+00:00

The MSDN docs for volatile in Visual C++ indicate that writes have release semantics

  • 0

The MSDN docs for “volatile” in Visual C++ indicate that writes have “release semantics” and that reads have “acquire semantics”, in addition to ensuring that reads always read from memory and that writes always write accordingly.

The C spec for “volatile” includes the second part (don’t do crazy optimizations), but not the first part (a memory fence).

Is there any way in Visual C++ to get the “C” volatile behaviour only, without the memory fence?

I want to force a variable to always be on the stack, in a fixed spot, but I don’t want to take the overhead of a memory fence on every assignment to it.

Is there any easy way to do that with Visual C++ source?

  • 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-05-25T17:40:16+00:00Added an answer on May 25, 2026 at 5:40 pm

    Is there any way in Visual C++ to get the “C” volatile behaviour only, without the memory fence?

    On x86 there are no memory fences created at the assembly level on reads and writes to a volatile memory location since on that platform every load has acquire semantics, and every store has release semantics. Therefore for MSVC on x86, the volatile directive simply directs the compiler to prevent the reordering of loads and stores depending on if you are writing or reading from the memory location that was marked volatile.

    You would only incur the “penalty” of a memory fence on the IA64 architecture, since there the memory ordering model of the platform does not ensure acquire and release semantics for loads and stores.

    Keep in mind this behavior is MSVC-specific, and is not a standardized semantic of volatile.

    Update: According to @ildjarn you would also see a memory fence on ARM with Windows 8 since that platform also has a weakly ordered memory-consistency model like IA64.

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

Sidebar

Related Questions

MSDN docs say that only value types need boxing, but this does not apply
MSDN docs state An expression is a fragment of code that can be evaluated
According to the msdn docs for System.Security.Cryptography.SymmetricAlgorithm Note that when using derived classes, it
The MSDN docs state: In Silverlight, the BeginInvoke method that is automatically defined on
I understand from the MSDN docs that the event DataReceived will not necessarily fire
According to the docs: http://msdn.microsoft.com/en-us/library/x13ttww7.aspx : The volatile keyword can be applied to reference
MSDN says that you should use structs when you need lightweight objects. Are there
MSDN states that String.Intern retrieves the system's reference to the specified String and String.IsInterned
MSDN says that public static members of System.Windows.Application are thread safe. But when I
Microsoft's docs say: Specifies that the corresponding point in lpPoints is a control point

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.