From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8214 invoked by alias); 6 Feb 2009 19:40:03 -0000 Received: (qmail 8091 invoked by uid 48); 6 Feb 2009 19:39:51 -0000 Date: Fri, 06 Feb 2009 19:40:00 -0000 Subject: [Bug c/39121] New: strange behavior of a chain of operations. X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "nospam at pamies dot cat" 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: 2009-02/txt/msg00585.txt.bz2 #include /* Why the first swap operation works as expected but it does not happen the same with the second one ? I guess that it can be due operations within temp values, but IMHO swap operation should work in both cases. Thanks ! */ void swap(int *a, int *b) { *a ^= *b ^= *a ^= *b; } int main() { int a = 5; int b = 8; printf("%d, %d\n", a, b); a ^= b ^= a ^= b; printf("%d, %d\n", a, b); swap(&a, &b); printf("%d, %d\n", a, b); } -- Summary: strange behavior of a chain of operations. Product: gcc Version: unknown Status: UNCONFIRMED Severity: major Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: nospam at pamies dot cat http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39121