https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93903

            Bug ID: 93903
           Summary: invalid input constraint in __asm__
           Product: gcc
           Version: 8.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 1059252359 at qq dot com
  Target Milestone: ---

Hi,
When compiling the below testcase, gcc reports two ambiguous errors as follows
: 
            testcase.c: In function ‘main’:
            testcase.c:10:5: error: invalid punctuation‘ ’ in constraint
               10 |     );
                  |     ^
            testcase.c:5:3: error: invalid punctuation ‘ ’ in constraint
                5 |   __asm__("movl %1, %%eax\n\t"
                  |   ^~~~~~~
It seems to mean that the invalid input constraint 'r ' in asm in line 8. But
gcc document says that whitespace characters are ignored and can be inserted at
any position except the first.(URL:
https://gcc.gnu.org/onlinedocs/gcc/Simple-Constraints.html#Simple-Constraints)
So Is this a correct behavior for gcc complier?

TestCase:
#include <stdio.h>
int main()
{
  int a = 10, b;
  __asm__("movl %1, %%eax\n\t"
    "movl %%eax, %0\n\t"
    :"=r"(b)
    :"r "(a)
    :"%eax"
    );
  printf("Result: %d, %d\n", a, b);
  return 0;
}

Compiler Version:
gcc (GCC) 8.2.0

The OS is:
Linux version 4.15.0-65-generic

Reply via email to