https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113341
--- Comment #13 from John Paul Adrian Glaubitz <glaubitz at physik dot fu-berlin.de> --- (In reply to Andrew Pinski from comment #7) > `-fno-lifetime-dse` is already used but I get the feeling there might be > strict aliasing issues in the code though. What happens if you add > -fno-strict-aliasing ? > > This code gives me strict aliasing violation vibes: > ``` > T **getAddressOfPointer(ExternalASTSource *Source) const { > // Ensure the integer is in pointer form. > (void)get(Source); > return reinterpret_cast<T**>(&Ptr); > } > ``` I tried with the following diff but that did not fix the issue: diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index 5ca580fbb59c..51c470dcc3ed 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -679,7 +679,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # crash if LLVM is built with GCC and LTO enabled (#57740). Until # these bugs are fixed, we need to disable dead store eliminations # based on object lifetime. - append("-fno-lifetime-dse" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-fno-lifetime-dse -fno-strict-aliasing" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) endif () # Modules enablement for GCC-compatible compilers: