How to prevent optimizer from reordering stuff?
Dan Olson via digitalmars-d-ldc
digitalmars-d-ldc at puremagic.com
Sun Mar 15 20:56:00 PDT 2015
Ok, I have stumbled into an old problem it seems.
C99 invented "#pragma STDC FENV_ACCESS ON" to prevent optimizer from
reordering instructions that affect float environment. See note [2]
here:
http://en.wikipedia.org/wiki/C99#Example
And clang (LLVM) does not support this pragma:
https://llvm.org/bugs/show_bug.cgi?id=10409
Work around in C is to use volatile vars to force ordering.
And one more reference:
http://wiki.musl-libc.org/wiki/Mathematical_Library#Fenv_and_error_handling
More information about the digitalmars-d-ldc
mailing list