This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/55095] Wshift-overflow
- From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 25 May 2015 09:29:53 +0000
- Subject: [Bug c++/55095] Wshift-overflow
- Auto-submitted: auto-generated
- References: <bug-55095-4 at http dot gcc dot gnu dot org/bugzilla/>
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.