Open scabug opened 9 years ago
Imported From: https://issues.scala-lang.org/browse/SI-9053?orig=1 Reporter: @szeiger Affected Versions: 2.11.2, 2.11.4
@szeiger said: Checking the bytecode, the volatile reads are still generated (as they should be). It's just the warning that is wrong.
@retronym said: Workaround if you want to silence to warning:
def volatileRead() = ctx.sync
volatileRead()
Scala 2.11 warns about pure expressions in statement position. This warning is incorrect for volatile reads. A volatile read has the side-effect of inserting a memory read barrier (which must not be optimized away by the JIT even when the actual read is unnecessary and can be removed).