Re: Arithmetic Shift

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

 



On Thu, Dec 9, 2010 at 20:13, Paul Eggert <eggert@xxxxxxxxxxx> wrote:
> On 12/07/10 20:41, Mike Gibson wrote:
>> Does a test already exist that checks for if the >> operator in C does
>> arithmetic shift?
>
> Doesn't this suffice, without dragging Autoconf into it?
>
> #if -1 >> 1 == -1

No.  It won't work.  Your preprocessor directive checks behavior of
the preprocessor (/bin/cpp for example) that may have nothing with the
behavior of the compiler and behavior of the code generated by
compiler.

In another words:

#if -1 >> 1 == -1
check preprocessor only

int i = -1 >> 1; if (i == -1) {}
may be evaluated at the compile time and therefore may check the
compiler itselt, not the code generated by compiler (which also
important).

volatile int i = -1; i = i >> 1; if (i == -1) {}
force bypass the optimizer, enforce check for generated code

-- 
Andrew W. Nosenko <andrew.w.nosenko@xxxxxxxxx>

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf


[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux