[Top][All Lists]

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

Re: NSK(OSS) compilation problem

From: Paul Eggert
Subject: Re: NSK(OSS) compilation problem
Date: Tue, 07 Nov 2006 12:43:38 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

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.

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

#include <limits.h>
#include <stdio.h>

#ifndef LLONG_MAX
# define HALF_LLONG_MAX (1LL << (sizeof (long long int) * CHAR_BIT - 2))

main (void)
  long long int n = 1;
  int i;
  for (i = 0; ; i++)
      long long int m = n << i;
      if (m >> i != n)
          printf ("shift %d failed\n", i);
          return 1;
      if (LLONG_MAX / 2 < m)

  return 0;

reply via email to

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