https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67301
Bug ID: 67301
Summary: Unable to compile program using extended assembly and
asmSymbolicName
Product: gcc
Version: 4.9.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: driver
Assignee: unassigned at gcc dot gnu.org
Reporter: noloader at gmail dot com
Target Milestone: ---
The following program:
$ cat test.cxx
int main(int argc, char* argv[])
{
__asm__ __volatile__ (
"\t movl %[__ARGC], %%eax \n"
:
: __ARGC "" (argc)
);
return 0;
}
Results in a failed compile:
$ g++ test.cxx
test.cxx: In function ‘int main(int, char**)’:
test.cxx:7:5: error: expected string-literal before ‘__ARGC’
: __ARGC "" (argc)
^
test.cxx:7:5: error: expected ‘(’ before ‘__ARGC’
test.cxx:7:5: error: ‘__ARGC’ was not declared in this scope
test.cxx:7:12: error: expected ‘)’ before string constant
: __ARGC "" (argc)
^
test.cxx:7:12: error: expected ‘)’ before string constant
Above, I am trying to use GCC's extended ASM like Microsoft's MASM.
According to the online manual and Assembler Instructions with C Expression
Operands, § 6.44.3.1 Input Operands
(https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html), asmSymbolicName is
being used correctly.
Operands are separated by commas. Each operand has this format:
[ [asmSymbolicName] ] constraint (cexpression)
asmSymbolicName
Specifies a symbolic name for the operand. Reference the name in the
assembler template by enclosing it in square brackets (i.e. ‘%[Value]’).
The scope of the name is the asm statement that contains the definition.
Any valid C variable name is acceptable, including names already defined
in the surrounding code.