Hi : $ cat /tmp/p.c int foo() { int a; asm("nop" : : "m"((int)(a)) ); } $ ./llvm/tools/clang/tools/ccc/ccc /tmp/p.c -c -o /tmp/p.o /tmp/p.c:6:10: error: invalid lvalue in asm input for constraint 'm' : "m"((int)(a)) ^~~~~~~~ 1 diagnostic generated. The casting should be the same thing than doing : int foo() { int a; int tmp = a; asm("nop" : : "m"(tmp) ); }
I'm sorry, but this is a bug that we don't want to be compatible with. "m" operands require that you be able to take the address of the operand. (int)x is an rvalue, and x is an lvalue. We need an lvalue.
*** Bug 3794 has been marked as a duplicate of this bug. ***
I'm considering adding support for making the inline asm code ignore casts to the exact same type, but would make this an error by default requiring some funny option to enable it. Would that fix this problem?
(In reply to comment #3) > I'm considering adding support for making the inline asm code ignore casts to > the exact same type, but would make this an error by default requiring some > funny option to enable it. Would that fix this problem? > Yes.
What about only allowing this when using -std=gnu*?
we default to gnu mode. I'll add something like -fheinous-gnu-extensions
Implemented here: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20090309/013929.html