In C/C++, are volatile variables guaranteed to have eventually consistent semantics betwen threads?

前端 未结 6 794
猫巷女王i
猫巷女王i 2020-12-16 02:29

Is there any guarantee by any commonly followed standard (ISO C or C++, or any of the POSIX/SUS specifications) that a variable (perhaps marked volatile), not guarded by a m

6条回答
  •  太阳男子
    2020-12-16 03:04

    This is a potential data race.

    With respect to POSIX thread, this is UB. Same with C++ I believe.

    In practice I cannot imagine how it could fail.

提交回复
热议问题