[Bug c/44828] possible integer wrong code bug

2010-07-06 Thread rguenth at gcc dot gnu dot org
--- Comment #4 from rguenth at gcc dot gnu dot org 2010-07-06 13:38 --- Subject: Bug 44828 Author: rguenth Date: Tue Jul 6 13:37:58 2010 New Revision: 161869 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161869 Log: 2010-07-06 Richard Guenther PR middle-end/44828

[Bug c/44828] possible integer wrong code bug

2010-07-06 Thread rguenth at gcc dot gnu dot org
--- Comment #3 from rguenth at gcc dot gnu dot org 2010-07-06 10:35 --- The bug is that we have in .original { return si1 * si2; } while it should have been { return (char)((unsigned char) si1 * (unsigned char) si2); } which is premature optimization by convert_to_integer, short-

[Bug c/44828] possible integer wrong code bug

2010-07-06 Thread jakub at gcc dot gnu dot org
--- 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 beh

[Bug c/44828] possible integer wrong code bug

2010-07-06 Thread jakub at gcc dot gnu dot org
--- Comment #1 from jakub at gcc dot gnu dot org 2010-07-06 09:25 --- Shorter testcase: extern void abort (void); static char foo (char si1, char si2) { return si1 * si2; } int a = 0x105F61CA; int main (void) { int b = 0x0332F5C8; if (foo (b, a) > 0) abort (); return 0; }