This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c/2597: gcc 3.0 branch rejects legal extended asm
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c/2597: gcc 3.0 branch rejects legal extended asm
- From: test_alpha at hotmail dot com
- Date: 20 Apr 2001 04:55:40 -0000
- Reply-To: test_alpha at hotmail dot com
>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 <stdio.h>
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;
}