From mboxrd@z Thu Jan 1 00:00:00 1970 From: test_alpha@hotmail.com To: gcc-gnats@gcc.gnu.org Subject: c/2597: gcc 3.0 branch rejects legal extended asm Date: Thu, 19 Apr 2001 21:56:00 -0000 Message-id: <20010420045540.6676.qmail@sourceware.cygnus.com> X-SW-Source: 2001-04/msg00352.html List-Id: >Number: 2597 >Category: c >Synopsis: gcc 3.0 branch rejects legal extended asm >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Thu Apr 19 21:56:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Nick >Release: gcc version 3.0 20010418 (prerelease) >Organization: >Environment: i386-pc-linux-gnu >Description: this version of gcc rejects legal extended asm seemingly when an output/input (+ constraint) operand is negative and could be a register (r, g, etc constraint). >How-To-Repeat: try to compile the file - it fails. try commenting out the last 3 printf statements and it works. >Fix: do not inline or with the following diff: __asm__ ( "subl %1, %0\n\t" - : "+r"(a) - : "r"(b) + : "=r"(a) + : "r"(b), "0"(a) ); return a; >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="a.c" Content-Disposition: inline; filename="a.c" #include typedef signed long int32; /* a - b */ static inline int32 subtract(int32 a, int32 b) { __asm__ ( "subl %1, %0\n\t" : "+r"(a) : "r"(b) ); return a; } int main(void) { printf("10 - 5 = %i\n", subtract(10, 5)); printf("5 - 10 = %i\n", subtract(5, 10)); printf("-5 - -10 = %i\n", subtract(-5, -10)); printf("-10 - 5 = %i\n", subtract(-10, 5)); return 0; }