Neither clang nor GCC like this very much with -m32:
long long ret;
asm ("movb $5, %0" : "=q" (ret));
However, GCC can tolerate this variant:
long long ret;
switch (sizeof(ret)) {
case 1:
asm ("movb $5, %0" : "=q" (ret));
case 8:
;
}
Clang, on the other hand, won't accept that because it validates the
inline asm for the '1' case *before* the optimisation phase where it
realises that it wouldn't have to emit it anyway.
This patch puts some casts in to make clang less unhappy. I don't like
it very much.
Note that we don't have the same problem for the "=r" case, where a
64-bit value *also* doesn't fit. This is because even if it *does* have
to emit it, clang will happily and silently do so even though it's
clearly bogus:
long long ret;
asm ("movl $5, %0" : "=r" (ret));
$ clang -c -o q.o q.c -m32
$ gcc -c -o q.o q.c -m32
q.c: In function ‘foo’:
q.c:6:1: warning: unsupported size for integer register