https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91555
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Daniel Richard G. from comment #6) > Unfortunately, this GCC build does not have libsanitizer, as it is on an > older (Linux) system without the necessary system headers. > > $ gcc -O2 -fsanitize=undefined gcc9-opt-bug.c -o bug > /usr/bin/ld: cannot find -lubsan > collect2: error: ld returned 1 exit status > > (I get a similar error on the Solaris system.) > > Are you able to reproduce the -O1/-O2 split in behavior? Well -O2 enables VPR which is known to expose undefined signed integer overflow issues. This is why it might only be exposed at -O2 and above.