https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81763
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- There are some known issues with older versions of LLVM, maybe you are using too older version of LLVM. That is some versions of LLVM have undefined C++ code in them. GCC 7.1 is more aggressive of optimizing things.