Skip to content

Is the ECMA-334 example for volatile fields correct? #8692

Answered by delreluca
delreluca asked this question in Q&A
Discussion options

You must be logged in to vote

I think this is a possible interpretation, Stephen, however the section talks about reorderings in the instruction sequence without defining the term precisely (at least I was not able to find it; the only thing I was able to deduce is that it’s about the temporal sequence of instructions not the instruction as they are laid out in the code listing).

The question is whether other optimisations leading to non-reordering changes (as a non-benevolent reader might argue that collapsing the reads is not a reordering) are also prohibited.

Funnily, since I had to go through the C# spec again, I found section 7.10 which talks about the preservation of side effects:

Emphasis mine:

7.10 Execution …

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@delreluca
Comment options

@CyrusNajmabadi
Comment options

@stephentoub
Comment options

@delreluca
Comment options

Answer selected by delreluca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants