Function test has value 0. Should have value 1; #include <stdio.h> int a=0x101; int b=0x100; int test(){ return ( ((unsigned char)(unsigned long long) ( (a?a:1) & (a*b) )) ? 0 : 1 ); } int main(void){ if((unsigned char)(unsigned long long) (a&(a*b)))return 2; if( test() ){ printf("successful\n"); return 0; } else { printf("failed\n"); return 1; } } Related to Bug 19606? GNU CPP version 2.95.2 19991024 (release) (sparc) successful GNU C version 3.3.3 (sparc-sun-solaris2.8) failed GNU CPP version 3.2 (cpplib) (i386 Linux/ELF) failed GNU C version 3.3.2 (i686-pc-linux-gnu) failed GNU C version 3.3.5 (i686-pc-linux-gnu) failed GNU C version 3.4.3 (i686-pc-linux-gnu) failed
Confirmed, only a regression on the 3.4 branch.
This is another symptom of the same bug as PR19283. I'm testing a backport of that patch.
Subject: Bug 20187 CVSROOT: /cvs/gcc Module name: gcc Changes by: rsandifo@gcc.gnu.org 2005-07-28 16:27:22 Modified files: gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.c-torture/execute: pr20187-1.c Log message: PR c/20187 * gcc.c-torture/execute/pr20187-1.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5842&r2=1.5843 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/pr20187-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 20187 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: rsandifo@gcc.gnu.org 2005-07-28 16:30:51 Modified files: gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.c-torture/execute: pr20187-1.c Log message: PR c/20187 * gcc.c-torture/execute/pr20187-1.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.306&r2=1.5084.2.307 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/pr20187-1.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
Subject: Bug 20187 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: rsandifo@gcc.gnu.org 2005-07-28 16:34:42 Modified files: gcc : ChangeLog fold-const.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.c-torture/execute: pr20187-1.c Log message: PR c/20187 * fold-const.c (fold): When shortening comparisons of widened operands, check whether the tree returned by get_unwidened really is wider. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.886&r2=2.2326.2.887 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.322.2.17&r2=1.322.2.18 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.412&r2=1.3389.2.413 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/pr20187-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.4.1
Patch applied to 3.4 branch. Testcase also applied to 4.0 and mainline (where it already passes).