This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c/2597: gcc 3.0 branch rejects legal extended asm



>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;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]