This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

strange compiling problem


Hi,

I'm not sure if I'm doing something stupid or not, but the following code does odd things to g++-3.3.1. If I compile it with -O(or higher), it compiles and runs, no problem. But if I try to compile without optimization, I get "error: inconsistent operand constraints in an `asm'". I really think this is a bug in g++, but It's also possible I am misunderstanding the rather poor inline asm documentation. In any case, could someone please look at this and tell me what's going on, and how to fix it, before I go insane?

#include <iostream>
using namespace std;

int main(void)
{
   int a=1;
   int b=2;
   int &ra=a;
   int &rb=b;

   asm(" movl  %0, %%eax\n\
         add   %2, %%eax\n\
         movl  %%eax, %0\n\
      "
      :"=m"(ra)
      :"0"(ra), "m"(rb)
      :"%eax"
      );
   cout << a << endl;
   return 0;
}

Thanks,

Kyle Centers
-- 
__________________________________________________________
Sign-up for your own personalized E-mail at Mail.com
http://www.mail.com/?sr=signup

CareerBuilder.com has over 400,000 jobs. Be smarter about your job search
http://corp.mail.com/careers


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]