clang-cc regression on inline asm?

Hello.

Both clang-cc SVN version 68830 and gcc 4.3.2 accept the following chunk of code (which was extracted from linux-2.4.37):

If you mean, does it work in gcc and not in clang yet, yes, it is a regression from gcc to clang. If you're asking if it is a bug, yes, it is. You can work around this by ensuring that the input and output types are the same, something like:

typedef struct {
   volatile unsigned int lock;
} spinlock_t;

int spin_trylock(spinlock_t *lock)
{
   char oldval;
   __asm__ __volatile__(
           "xchgb %b0,%1"
           :"=q" (oldval), "=m" (lock->lock)
           :"0" ((char)0) : "memory");
   return oldval > 0;
}

Do we have an open PR that covers this issue?

  - Doug

I think he is asking if it is an intentional incompatibility, and I
think, but am not sure, that Chris did intend to make this an error
and expect users to change their code.

- Daniel

Douglas Gregor wrote:

Yes, that (the behavior as it is now) is what Chris intended, he would rather people change their code.... It is expedient for now, but I have my doubts that we won't run across some random large code base that we'll want to `improve' compatibility for. :slight_smile:

Daniel Dunbar wrote:

I think he is asking if it is an intentional incompatibility, and I
think, but am not sure, that Chris did intend to make this an error
and expect users to change their code.

The problem is that there is code (lots of code) we cannot change.
What Enea was asking is a confirmation that this is a regression
from clang-cc SVN version 68830 (which is able to parse linux-2.4.37)
   to clang-cc SVN version 72105 (which is not).

     Roberto