[CMAKE] Add -fno-aggressive-loop-optimizations flag

ReactOS/Windows headers contain lots of structures whose last field is
fieldName[ANYSIZE] or fieldName[1].
Starting with GCC 4.8, gcc considers that accessing items [2], [3], ...
are undefined operation, and may optimize those accesses by removing them!

Add flag -fno-aggressive-loop-optimizations to prevent this unwanted behaviour.
This commit is contained in:
Hervé Poussineau 2019-03-31 08:40:36 +02:00
parent 6668178cff
commit 95671c25ec

View file

@ -46,6 +46,7 @@ add_compile_flags("-nostdinc")
if(GCC_VERSION VERSION_GREATER 4.7) if(GCC_VERSION VERSION_GREATER 4.7)
add_compile_flags("-mstackrealign") add_compile_flags("-mstackrealign")
add_compile_flags("-fno-aggressive-loop-optimizations")
endif() endif()
if(CMAKE_C_COMPILER_ID STREQUAL "Clang") if(CMAKE_C_COMPILER_ID STREQUAL "Clang")