This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/79818] [7 Regression] wrong code with -fwrapv and -Os/-O1/-O2/-O3
- From: "glisse at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 02 Mar 2017 13:13:03 +0000
- Subject: [Bug middle-end/79818] [7 Regression] wrong code with -fwrapv and -Os/-O1/-O2/-O3
- Auto-submitted: auto-generated
- References: <bug-79818-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79818
--- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> ---
We have ++c on signed char, which gcc turns into c=c+1, still on signed char,
where overflow is undefined behavior. The problem is long before the
transformation of the comparison. If ++c means c=(signed char)((int)c+1), it
should be lowered to that, or to an unsigned char addition.