LINUX.ORG.RU

История изменений

Исправление shdown, (текущая версия) :

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf

35 The execution of a program contains a data race if it contains two conflicting actions in different threads, at least one of which is not atomic, and neither happens before the other. Any such data race results in undefined behavior

Стандарт считает, что volatile — это не atomic, и операции над volatile не atomic. Ты с этим будешь спорить?

Вот, например, слова, которые показывают, что стандарт не считает accessing a volatile object == atomic operations:

An iteration statement may be assumed by the implementation to terminate if its controlling expression is not a constant expression,186) and none of the following operations are performed in its body, controlling expression or (in the case of a for statement) its expression-3: 187)

— input/output operations

— accessing a volatile object

— synchronization or atomic operations.

Исходная версия shdown, :

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf

35 The execution of a program contains a data race if it contains two conflicting actions in different threads, at least one of which is not atomic, and neither happens before the other. Any such data race results in undefined behavior

Стандарт считает, что volatile — это не atomic, и операции над volatile не atomic. Вы с этим будете спорить?

Вот, например, слова, которые показывают, что стандарт не считает accessing a volatile object == atomic operations:

An iteration statement may be assumed by the implementation to terminate if its controlling expression is not a constant expression,186) and none of the following operations are performed in its body, controlling expression or (in the case of a for statement) its expression-3: 187) — input/output operations — accessing a volatile object — synchronization or atomic operations.