Paul Eggert wrote: > In my weaker moments I sometimes think we should declare every test-case > variable volatile, along the lines of the "volatile-by-default" approach > for Java. See: > > Liu L, Millstein T, Musuvathi M. Safe-by-default concurrency for modern > programming languages. ACM TOPLAS. 2021;43(3):10. > https://doi.org/10.1145/3462206
Well, the problem with doing that is that test cases are more useful if they are run in the same environment / with the same optimizations as the production code. Adding 'volatile-by-default' to the tests and 'relaxed' to the production code reduces the value of the tests. It's like compiling the tests with -O0 and the production code with -O6. For this reason, we need to continue to put 'volatile' only on selected variables. Bruno