https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55095
--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> --- I've started looking into this. Unfortunately, int_const_binop_1 doesn't say whether an overflow occurred for e.g. 10 << 30. So what we need to do is something akin to what I did in cxx_eval_check_shift_p (I should have done that using wide_int...). It's also what our ubsan does when checking for overflows, only at runtime. build_binary_op then should be able to use that trick in case it's dealing with INTEGER_CSTs, and warn appropriately. It also seems we need yet another shift warning, -Wshift-overflow.