https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71246

            Bug ID: 71246
           Summary: "+g" assembly constraint causes error: inconsistent
                    operand constraints in an 'asm'
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: inline-asm
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eric at efcs dot ca
  Target Milestone: ---

The following code fails to compile with the error "inconsistent operand
constraints in an 'asm'". It seems to also be triggered when the constrain is
stated as "+rm" which makes more sense.

Previous versions of GCC ICE'd on this code.

template <class Tp>
inline __attribute__((__always_inline__)) 
void DoNotOptimize(Tp const& value) {
    asm volatile("" : "+g" (const_cast<Tp&>(value)));
}

struct Foo {
  int Arr[42];
};

void test2() {
  Foo f = {};
  DoNotOptimize(f);
}

There are a couple of similar bugs but I'm not certain they are duplicates so
I'm filing this separately.

Reply via email to