From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2765 invoked by alias); 22 May 2002 11:26:03 -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 2742 invoked by uid 71); 22 May 2002 11:26:02 -0000 Resent-Date: 22 May 2002 11:26:02 -0000 Resent-Message-ID: <20020522112602.2741.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, jompo@abi.snv.jussieu.fr Received:(qmail 2557 invoked by uid 61); 22 May 2002 11:25:23 -0000 Message-Id:<20020522112523.2556.qmail@sources.redhat.com> Date: Wed, 22 May 2002 04:26:00 -0000 From: jompo@abi.snv.jussieu.fr Reply-To: jompo@abi.snv.jussieu.fr To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c/6765: gcc - incrementation - ternary operator X-SW-Source: 2002-05/txt/msg00667.txt.bz2 List-Id: >Number: 6765 >Category: c >Synopsis: gcc - incrementation - ternary operator >Confidential: no >Severity: non-critical >Priority: low >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Wed May 22 04:26:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Pothier Joel >Release: gcc 2.95.2 - gcc 2.95.3 - gcc 3.04 >Organization: >Environment: gcc 2.95.3, gcc 3.04 (home compiled on Linux Mandrake 8.1) Mac OS X : gcc 2.95.2 >Description: the ternary operator causes incrementation of left hand side expression to occurs before it should in an expression where the variable appears at both side of the affectation expression. example: *s++ = (*s == 'x') ? 'X': *s; Note: this does not appears in gcc-2.96 (Mandrake 8.2) >How-To-Repeat: #include #define STRING "abc" int main() { char s[10], *t; strcpy(s, STRING); t = s; while (*t != '\0') *t++ = (*t == 'b') ? 'X': *t; /* this print "Xc" instead of "aXc" */ printf("%s\n",s); } >Fix: Must replace ternary operator by if/else instruction >Release-Note: >Audit-Trail: >Unformatted: