Title
Visible side effects and initial value of an object
Status
review
Section
6.9.2.2 [intro.races]
Submitter
Andrey Erokhin

Created on 2022-05-10.00:00:00 last changed 9 months ago

Messages

Date: 2023-06-20.19:34:52

Proposed resolution:

Change in 6.9.1 [intro.execution] paragraph 7 as follows:

Reading an object designated by a volatile glvalue (7.2.1 [basic.lval]), modifying an object (including initialization), calling a library I/O function, or calling a function that does any of those operations are all side effects, which are changes in the state of the execution environment. ...
Date: 2022-05-10.00:00:00

Subclause 6.9.2.2 [intro.races] paragraph 13 specifies:

A visible side effect A on a scalar object or bit-field M with respect to a value computation B of M satisfies the conditions:
  • A happens before B and
  • there is no other side effect X to M such that A happens before X and X happens before B.
The value of a non-atomic scalar object or bit-field M, as determined by evaluation B, shall be the value stored by the visible side effect A.

However, a side effect is defined as 6.9.1 [intro.execution] paragraph 7:

Reading an object designated by a volatile glvalue (7.2.1 [basic.lval]), modifying an object, calling a library I/O function, or calling a function that does any of those operations are all side effects, which are changes in the state of the execution environment.

It seems that initialization of an object is not a side effect, and thus the value of an scalar object can never be the value obtained during initialization.

History
Date User Action Args
2023-06-20 19:34:52adminsetmessages: + msg7333
2023-06-20 19:34:52adminsetstatus: open -> review
2022-05-10 00:00:00admincreate