this program aborts if compiled with any options: ---------------------------------------------------------------------------------------- extern void abort (void); int foo (int k) { unsigned char j = 0; (k ? 0 : j++) == -1; return j; } int main () { if (!foo (0)) abort (); return 0; } ----------------------------------------------------------------------------------------
We are getting rid of " (k ? 0 : j++) == -1;" for some reason even though it has side effects.
Subject: Bug 18921 CVSROOT: /cvs/gcc Module name: gcc Changes by: sayle@gcc.gnu.org 2004-12-11 13:46:37 Modified files: gcc : ChangeLog fold-const.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: pr18921-1.c Log message: PR middle-end/18921 * fold-const.c (fold_unwidened_comparison): Use omit_one_operand instead of constant_boolean_node as arg0 may have side-effects. * gcc.dg/pr18921-1.c: New test case. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.6780&r2=2.6781 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&r1=1.483&r2=1.484 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4738&r2=1.4739 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr18921-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Fixed.