------- Comment #2 from jakub at gcc dot gnu dot org  2010-07-06 09:33 -------
Not sure whether the testcase is valid or not.  The multiplication using char
variables on both sides (and likewise for result) is: -54 * -56 (= 3024),
but (char) 3024 is -48.  For int that would be clear undefined behavior, but
for char the multiplication is promoted to int, so it is (char) (int * int).
*.ccp1 has:
  char D.2741;
  char D.2741;
  char si2;
  int D.2727;
  char D.2726;
  int a.0;

<bb 2>:
  a.0_2 = a;
  D.2726_3 = (char) a.0_2;
  D.2727_4 = (int) D.2726_3;
  si2_11 = (char) D.2727_4;
  D.2741_12 = si2_11 * -56;
  D.2741_13 = D.2741_12;
  D.2741_7 = D.2741_13;
  if (D.2741_7 > 0)

but forwprop1 uses if (si2_11 < 0) test instead.  If the testcase is valid, we
shouldn't assume undefined overflow for char and short operations.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44828

Reply via email to