From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11903 invoked by alias); 3 Aug 2007 04:47:14 -0000 Received: (qmail 11881 invoked by uid 48); 3 Aug 2007 04:47:05 -0000 Date: Fri, 03 Aug 2007 04:47:00 -0000 Subject: [Bug inline-asm/32971] New: Inline asm with offset addressing fails to compile in 4.0+ without -O X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "kinetik at orcon dot net dot nz" 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: 2007-08/txt/msg00140.txt.bz2 The following test case fails to compile without optimization with gcc 4.3.0 (20070503 (experimental)), 4.1.2 (20070502 (Red Hat 4.1.2-12)), and 4.0.4 (20060904 (prerelease) (Debian 4.0.3-7)), but succeeds with 3.3.6 (Debian 1:3.3.6-15) and 3.4.6 (Debian 3.4.6-5). With optimization (-O and -O2), it compiles fine with all of the gcc versions mentioned above. The failing configurations are generating invalid assembly and gas emits the following error: /tmp/ccnbmIy1.s:12: Error: register value used as expression Looking at the assembly emitted by gcc, the failing case looks like: lea (%edx)(%eax), %eax ..and with the working configurations, I get the expected code: lea 4(%eax), %eax #include struct coord { int x; int y; }; int * foo(struct coord * c) { int * i; asm ("lea %1(%2), %0" : "=r" (i) : "m" (*(size_t *) offsetof(struct coord, y)), "r" (c) : "memory"); return i; } -- Summary: Inline asm with offset addressing fails to compile in 4.0+ without -O Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: inline-asm AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: kinetik at orcon dot net dot nz GCC build triplet: i486-linux-gnu GCC host triplet: i486-linux-gnu GCC target triplet: i486-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32971