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 1039341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:05:16+00:00 2026-05-16T15:05:16+00:00

Reference:- Modern C++ Design: Generic Programming and Design Patterns Applied by Andrei Alexandrescu Chapter

  • 0

Reference:- “Modern C++ Design: Generic Programming and Design Patterns Applied” by Andrei Alexandrescu
Chapter 6 Implementing Singletons.

Even if you put volatile then also it is not guaranteed to make Double Check locking pattern safe and portable.Why it is so?

If some one can put any good link that explains what is relaxed memory model and what is exactly problem with Double Check pattern.{Or someone can explain}

I used to think volatile has solve the problem but seems its not correct until I read the book.

  • 1 1 Answer
  • 1 View
  • 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-16T15:05:16+00:00Added an answer on May 16, 2026 at 3:05 pm

    Even if you put volatile then also it is not guaranteed to make Double Check locking pattern safe and portable.Why it is so?

    I’ll try to provide some context.

    There are three (Boehm & McLaren) portable use cases for volatile in C++ none of which has anything to do with multithreading. Alexandrescu did come up with a hack a long time back to cajole C++’s type system to help with multithreaded programming but that’s that. See David Butenhof’s reply on comp.programming.threads regarding the same.

    The confusion regarding this qualifier stems from the fact that with some compilers (Intel’s for example) volatile brings into play memory fence semantics — which is what you need for safe multithreading. But this is not portable and should not be relied upon.

    Further, most professional grade compilers fail to implement volatile flawlessly. See Regehr et al.

    Confusion probably gathers much from the fact that Java, the other language, has completely different semantics for volatile and they do involve memory fences. However, note that even the Double Checked Locking is not free from issues.

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

Sidebar

Related Questions

Andrei Alexandrescu writes in Modern C++ Design : The objects returned by typeid have
Based on chapter 5 (Generalized Functors) from the book Modern C++ Design, I'm trying
For reference I found this in C++ Solutions: Companion to The C++ Programming Language
Object reference not set to an instance of an object. using System; using System.Collections.Generic;
I'm still on my eternal quest to build (and understand) modern programming convention of
I am having following code which is taken from modern C++ design. While i
I'm pretty new to LINQ and a lot of modern data-driven application design techniques
In several modern programming languages (including C++, Java, and C#), the language allows integer
Reference: This is a self-answered question. It was meant to share the knowledge, Q&A
In reference with this question We have a header with a date picked component

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.