[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Arithmetic Shift
From: |
Andrew W. Nosenko |
Subject: |
Re: Arithmetic Shift |
Date: |
Fri, 10 Dec 2010 13:54:55 +0200 |
On Thu, Dec 9, 2010 at 20:13, Paul Eggert <address@hidden> 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 <address@hidden>
- Arithmetic Shift, Mike Gibson, 2010/12/09
- Re: Arithmetic Shift, Philip Herron, 2010/12/09
- Re: Arithmetic Shift, Paul Eggert, 2010/12/09
- Re: Arithmetic Shift, Mike Gibson, 2010/12/09
- Re: Arithmetic Shift,
Andrew W. Nosenko <=
- Re: Arithmetic Shift, Paul Eggert, 2010/12/10
- Re: Arithmetic Shift, Peter Breitenlohner, 2010/12/10
- Re: Arithmetic Shift, Andrew W. Nosenko, 2010/12/10
- Re: Arithmetic Shift, Bob Friesenhahn, 2010/12/10
- Re: Arithmetic Shift, Andrew W. Nosenko, 2010/12/11
Re: Arithmetic Shift, Ben Pfaff, 2010/12/10
Re: Arithmetic Shift, Paul Eggert, 2010/12/10
Re: Arithmetic Shift, Andrew W. Nosenko, 2010/12/11