https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115192
Bug ID: 115192 Summary: GCC 14.1.0 -O3 miscompilation on x86-64 (loops with vectors and scalars) Product: gcc Version: 14.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jukka.suomela at aalto dot fi Target Milestone: --- Created attachment 58268 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58268&action=edit Preprocessed source code It seems that GCC 14.1.0 with -O3 mis-compiles the attached code on x86-64. The key element seems to be loops that involve both arrays of vector types and arrays of scalar types. This is the expected output: $ g++-14 -Wall -Wextra -O2 test.cc -o test && ./test 0.000000 0.000000 3.000000 3.000000 9.000000 9.000000 This is the unexpected output that we got with -O3: $ g++-14 -Wall -Wextra -O3 test.cc -o test && ./test 0.000000 0.000000 3.000000 3.000000 6.000000 6.000000 I have attached the preprocessed source code produced by the following command, and I will attach also the full compiler output that I got: g++-14 -v -save-temps -Wall -Wextra -O3 test.cc -o test Compiler: GNU C++17 (Homebrew GCC 14.1.0) version 14.1.0 (x86_64-apple-darwin21), compiled by GNU C version 14.1.0, GMP version 6.3.0, MPFR version 4.2.1, MPC version 1.3.1, isl version isl-0.26-GMP, Target: x86_64-apple-darwin21.6.0. This is GCC on Intel-macOS from Homebrew, but we originally noticed the problem in Intel-Linux, so it doesn't seem to be specific to macOS or Homebrew. However, I wasn't able to reproduce the bug on Apple M3, so it might be specific to x86-64.