From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15688 invoked by alias); 22 Aug 2011 00:36:54 -0000 Received: (qmail 15372 invoked by uid 22791); 22 Aug 2011 00:36:52 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 22 Aug 2011 00:36:38 +0000 From: "thomas.c.zhao at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/50142] There is bug when swap elements of an array via chain expression. Date: Mon, 22 Aug 2011 03:33:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: critical X-Bugzilla-Who: thomas.c.zhao at gmail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg01802.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50142 --- Comment #2 from ZHAO Xiaogang 2011-08-22 00:36:34 UTC --- (In reply to comment #1) > Evaluation order is undefined since there is no sequence point involved. I don't think so. The associativity of operator ^= is Right to Left. I have build the code with other compiler. gcc 3.x is OK. Sun cc is OK. Microsoft VC is OK. If there isn't any array, it's also OK when use gcc4 build. main() { int a = 1, b = 2; a ^= b ^= a ^= b; printf("a=%d b=%d\n", a, b); } [expected result]: a=2 b=1 [actual result]: a=2 b=1 So, I guess, the defect associated with the gcc4 new feature which optimized array access.