following code doesnt compile with command "gcc -c  -O2 -o a.o a.c". It compiles
with any other -O flag. The error is:
a.c: In function `main':
a.c:7: error: inconsistent operand constraints in an `asm'

Here is the code:
typedef struct {
        unsigned long sig[2];
} sigset_t;

static __inline__ void sigaddset(sigset_t *set, int _sig)
{
        __asm__("btsl %1,%0" : "=m"(*set) : "Ir"(_sig - 1) : "cc");
}

extern int a(void);
int main (int argc, char **argv)
{
        sigset_t s;
        int i;

        for (i=0; i<64; i++)
                sigaddset (&s, i);
        a();
        return 0;
}

I tested it on Red Hat Enterprise Linux AS release 4. 
$ gcc --version
gcc (GCC) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)

-- 
           Summary: inline asm doesn't compile with -O2 optimization
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: inline-asm
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gleb76 at gmail dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-redhat-linux
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21396

Reply via email to