From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5171 invoked by alias); 30 Oct 2012 02:28:51 -0000 Received: (qmail 4395 invoked by uid 48); 30 Oct 2012 02:28:32 -0000 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug inline-asm/55131] Segmentation fault happened in resulting code (inline-asm) after upgraded g++ from 3.4.6 to 4.7.0 Date: Tue, 30 Oct 2012 02:28:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: inline-asm X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org 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: Status Component Version Resolution 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: 2012-10/txt/msg02814.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55131 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Component|c++ |inline-asm Version|unknown |4.7.0 Resolution| |INVALID --- Comment #1 from Andrew Pinski 2012-10-30 02:28:31 UTC --- This is not a bug. The produced assembly looks like: movl 8(%ebp), %edi # %1 movl 12(%ebp), %esi# %2 movl 0(%esi), %eax movl 4(%esi), %edx movl (%ecx), %ebx# %3 movl (%eax), %ecx# %4 By the time the last statement happens, eax has already been clobbered. You never said you are clobber eax in the inline-asm so it chose the 4th operand as being eax. You were getting lucky in 3.4.6 with the inline-asm really, I don't see why you don't use the __sync_* (or even better the __atomic_*) builtins for doing the compare and swap?