Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Sep 1998 20:22:41 -0400 (EDT)
From:      Simon Shapiro <shimon@simon-shapiro.org>
To:        freebsd-current@FreeBSD.ORG
Subject:   Compiler Problem in 64bit math?
Message-ID:  <XFMail.980927202241.shimon@simon-shapiro.org>

next in thread | raw e-mail | index | archive | help
The following fragment:

         off_t top_size    = QUAD_MAX,
               bottom_size = 0,
               half_size   = 0;

        do
        {
                        
           half_size = bottom_size + (top_size - bottom_size) / 2;
           switch ( seek_endpoint(device_fd, half_size) )
           {
             case -1:
               perror("lseek(2) failed while searching file size!");
               return( LSEEK_FAILED );
                           
             case -2:
             case 1:
               top_size = half_size;
               break;
                           
             case 0:
               bottom_size = half_size;
               break;
           }

           ndx++ ;
        }
        while ( (top_size - bottom_size) > 1 );

works correctly.  IF, however, I change the first line to be:

         register off_t top_size    = QUAD_MAX, ...

then the test at the bottom is always false.  This is with large numbers,
such as QUAD_MAX...




Sincerely Yours,                 Shimon@Simon-Shapiro.ORG
                                             770.265.7340
Simon Shapiro

Unwritten code has no bugs and executes at twice the speed of mouth


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.980927202241.shimon>