Message from C, C++ talks

June 2019

— About volatile, just yesterday seen this video.
Guys in Facebook made a check on some continuous integration machine that comments a paragraph about "volatile doesn't make your code thread-safe" into the code review, when it finds volatile going to be submitted not in a comment.

Message permanent page

— Volatile Is for other purposes

— Yes, but I for a long time thought that volatile bool can be used as a synchronization primitive. Before someone told me why it's not.
And there recently was a local conference in my city related to multithreading, and there were such code with volatile bool, and I've been told that there was a question from the audience and a long discussion, and it turned out that many of those who come to the conference thought it's an ok practice.

Message permanent page

— Why the fuck do people even THINK that volatile assures thread saftey?


"this is bool, how can it be not thread safe to set it in one thread and read from another. It can't be half-true, can it?"
That were my thoughts. I had no idea about instructions rearrangement and other more rare and complicated stuff.

— Lol

— Ah and also I heard that VS make volatile bool atomic by default. So it can work sometimes. But not sure if that true or rumors

Message permanent page

— That's true, but there is no justification to deprecate volatile, and it's still needed in other cases like interrupts

Message permanent page

— I never used it for that for example

— Check this out

— Https://

— What is difference between codeblocks and opencv

— Uh

— Google both?

— Yeah