https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108014
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I don't know if this is a bug really. The statement on line 9 (`e = b + 1;`) gets removed and therefor there was no undefined behavior that happens at all. Either DSE or CDDCE does the removal (depending on if you use -Og or -O1): Deleted trivially dead stmt: [/app/example.cpp:9:7] e_9 = (long int) _2; Deleted trivially dead stmt: [/app/example.cpp:9:11] _2 = .UBSAN_CHECK_ADD (2147483647, 1);