bug-coreutils
[Top][All Lists]
Advanced

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

Re: NSK(OSS) compilation problem


From: Matthew Woehlke
Subject: Re: NSK(OSS) compilation problem
Date: Tue, 07 Nov 2006 15:32:13 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060909 Thunderbird/1.5.0.7 Mnenhy/0.7.4.0

Paul Eggert wrote:
Matthew Woehlke <address@hidden> writes:
This simple test is OK on my Linux box and on NSK without -O. It does
not work /AT ALL/ (100% failure rate) on NSK with -O.

OK, but the C standard does not require that it has to work, because
it doesn't say what happens when you shift a negative integer right.
So the test program is too strict.

Eh? How is testing if ((1<<1)>>1) == 1 "too strict"? This fails. So do (1<<2)>>2, (1<<3)>>3, ..., (1<<62)>>62, none of which involve negative numbers...

In fact...
1<<1 seems to be 576460752437645312
576460752437645312>>1 seems to be 154618822656
1<<2 seems to be -9214821626686108448
-9214821626686108448>>2 seems to be 163208757248
...
Eek!

btw, was I supposed to see something different from your version? It is admittedly much more platform-agnostic (I wasn't trying :-)), but I didn't see anything that would cause me to expect yours to give different results.

What happens if you use the following test program instead?  That is,
what is the output of this program, and its exit status?  (Also,
assuming it outputs something and fails, what happens if you omit the
printf?  Does it still exit with status 1?)

(Using 'echo $?' in all cases...)
With the printf I get:
shift 1 failed
1

Without the printf I get:
1

Without using -O, all is well of course:
0

--
Matthew
"Try to bring it back in one piece this time." -- Q (MI6)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]