From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11023 invoked by alias); 24 May 2002 00:26:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 10994 invoked by uid 71); 24 May 2002 00:26:00 -0000 Resent-Date: 24 May 2002 00:26:00 -0000 Resent-Message-ID: <20020524002600.10993.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, horsh@mail.ru Received:(qmail 10102 invoked by uid 61); 24 May 2002 00:21:41 -0000 Message-Id:<20020524002141.10101.qmail@sources.redhat.com> Date: Thu, 23 May 2002 17:26:00 -0000 From: horsh@mail.ru Reply-To: horsh@mail.ru To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: optimization/6790: conditional expression as assignment lhs evaluated incorrectly X-SW-Source: 2002-05/txt/msg00754.txt.bz2 List-Id: >Number: 6790 >Category: optimization >Synopsis: conditional expression as assignment lhs evaluated incorrectly >Confidential: no >Severity: non-critical >Priority: medium >Responsible: unassigned >State: open >Class: ice-on-legal-code >Submitter-Id: net >Arrival-Date: Thu May 23 17:26:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: papahorsh >Release: 2.95.3 20010315 (SuSE), 3.1 >Organization: >Environment: Reading specs from /usr/lib/gcc-lib/i486-suse-linux/2.95.3/specs gcc version 2.95.3 20010315 (SuSE) or Reading specs from /pkg/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.1/specs Configured with: ../configure --prefix=/pkg/gnu --enable-languages=c++,f77 Thread model: posix gcc version 3.1 >Description: The following four little pieces should give identical results: $gcc test.c; ./a.out -2, -2, -2 , -2, 0, -2 -2, -2, -2 , -2, 0, -2 -2, -2, -2 , -2, 0, -2 -2, -2, -2 , -2, 0, -2 but they dont: gcc test.c; ./a.out -2, -2, -2 , -2, 0, -2 -4, -2, -2 , -2, 0, -2 -2, -2, -2 , -2, 0, -2 -2, -2, -2 , -2, 0, -2 $cat test.c void main(void) { int a, b, c, x, y, z, A, B, C, X, Y, Z; a=-2; b=-2; c=-2; x=-2; y=-2; z=-2; (y -= b); (c ? a : b) += (x ? y : z); printf("%d, %d, %d , %d, %d, %d\n", a, b, c, x, y, z); /*------------------------------------------------------------------*/ a=-2; b=-2; c=-2; x=-2; y=-2; z=-2; ( (y -= b) ? (c ? a : b) : (c ? a : b) ) += (x ? y : z); printf("%d, %d, %d , %d, %d, %d\n", a, b, c, x, y, z); /*------------------------------------------------------------------*/ a=-2; b=-2; c=-2; x=-2; y=-2; z=-2; ( (y -= b) ? ((c ? a : b) += (x ? y : z)) : ((c ? a : b) += (x ? y : z)) ); printf("%d, %d, %d , %d, %d, %d\n", a, b, c, x, y, z); /*------------------------------------------------------------------*/ a=-2; b=-2; c=-2; x=-2; y=-2; z=-2; ( (y -= b) ? ((c ? (a += (x ? y : z)) : (b += (x ? y : z)))) : ((c ? (a += (x ? y : z)) : (b += (x ? y : z)))) ); printf("%d, %d, %d , %d, %d, %d\n", a, b, c, x, y, z); } >How-To-Repeat: just compile and run: $gcc test.c; ./a.out >Fix: >Release-Note: >Audit-Trail: >Unformatted: