Re: Compile error when not using -ftree-ter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Job Noorman <jobnoorman@xxxxxxxxx> writes:

> Consider the following code snippet:
>
>     struct Foo
>     {
>         void foobar() {}
>     };
>
>     typedef void (*plain_foobar_t)(Foo*);
>
>     void test()
>     {
>         asm("push %0;"
>             :
>             : "i"((plain_foobar_t)&Foo::foobar));
>     }
>
>     int main(){}
>
> If I compile this with
>
>     g++ -Wno-pmf-conversions main.cpp
>
> I get the following;
>
>     main.cpp: In function ‘void test()’:
>     main.cpp:12: warning: asm operand 0 probably doesn’t match constraints
>     main.cpp:12: error: impossible constraint in ‘asm’


I would not expect this kind of thing to work when not optimizing.  You
are requiring the compiler to see that the value is an integer constant,
which the compiler can't reliably do when not optimizing.

It should work reliably with or without optimization if you use an "r"
constraint, though of course that will introduce an additional
instruction.

Ian



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux