Issue
Some extended assembly statements using the goto
qualifier fail to compile with GCC 10.1.0. Specifically,
int foo(int count)
{
asm goto ("dec %0; jb %l[stop]"
: "+r" (count)
:
:
: stop);
return count;
stop:
return 0;
}
(which is an example in the GCC extended asm docs) fails to compile with the message expected ‘:’ before string constant
. Removing the "+r" (count)
and the dec %0
allows it to compile successfully, but regardless of what I try whenever an output operand is supplied in the same asm statement as a goto label, it errors in this same way.
Solution
asm goto doesn't allow output operands.
It is a gnu decision. in the function c_parser_for_statement from c-parser.c you can find :
/* For asm goto, we don't allow output operands, but reserve
the slot for a future extension that does allow them. */
https://github.com/gcc-mirror/gcc/blob/releases/gcc-10/gcc/c/c-parser.c
However may be this situation will change since in the master branch this comment is not present anymore.
Answered By - yflelion Answer Checked By - Mary Flores (WPSolving Volunteer)