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

            Bug ID: 90791
           Summary: -Os accepts wrong code
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhonghao at pku dot org.cn
  Target Milestone: ---

My gcc is 10.0.0, and my code is:

void x()
{
 int a;
 __asm__ (
 "%0 %1"
 :"=r"(a));
}

gcc accepts the code with the following parameters:

gcc -Os | gcc -O3 | gcc -O1 | g++ -Os | g++ -O3 | g++ -O1 | 

With other parameters, it rejects the code:

<source>: In function 'void x()':

<source>:6:11: error: invalid 'asm': operand number out of range

    6 |  :"=r"(a));

      |           ^

Compiler returned: 1

Reply via email to