This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/31248] Too much casting for char operands on tree level
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Mar 2007 05:29:52 -0000
- Subject: [Bug tree-optimization/31248] Too much casting for char operands on tree level
- References: <bug-31248-1649@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from pinskia at gcc dot gnu dot org 2007-03-18 05:29 -------
You are wrong. The casts are correct as char + char in C is actually defined
as (int)(char) + (int) (char) aka promoted to int while doing the addition so
what the optimizers do when it sees (char)((int)(char) + (int)(char)), it
changes the addition to be (unsigned char)(char) + (unsigned char)(char) so the
addition's overflow is defined as being wrapping instead of being undefined.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31248