Usenet comp.unix.osf.misc (1992-2004)
 help / color / mirror / Atom feed
From: Charles M Richmond <cmr@iisc.com>
Subject: Re: cc bugs?
Date: 1996/07/23	[thread overview]
Message-ID: <31F55628.63DE@iisc.com> (raw)
In-Reply-To: Duzuwx.LIM@ukpsshp1.serigate.philips.nl


Stephen Baynes wrote:
> 
> Charles M Richmond (cmr@iisc.com) wrote:
> 
> : #include <stdio.h>
> 
> : main()
> : {
> :         unsigned long E1 = ~0 ;
> :         printf("%lu %x %lu %x %d %d\n",E1 >> 1,E1>>1,E1/2, E1/2,0x20,'\x20');
> :         return 0;
> : }
> 
> : koibito.iisc.com> make junk
> : cc   junk.c  -o junk
> : koibito.iisc.com> junk
> : 9223372036854775807 ffffffff 9223372036854775807 ffffffff 32 3158648
> : koibito.iisc.com> cc -std -o junk junk.c
> : koibito.iisc.com> junk
> : 9223372036854775807 ffffffff 9223372036854775807 ffffffff 32 32
> : koibito.iisc.com> cc -std1 -o junk junk.c
> : koibito.iisc.com> junk
> : 9223372036854775807 ffffffff 9223372036854775807 ffffffff 32 32
> : koibito.iisc.com> uname -a
> : OSF1 koibito.iisc.com V3.2 41 alpha
> 
> : So it is broken on 3.2d...
> 
> Looks like the '\x20' is broken for the first compile.
> I think the the rest of the stuff looks OK. The problem is you have used %x
> rather than %lx for the hex prints so are printing 32 rather than 64 bits and
> I belive your long is 64 bits.
> 
> [A quick calculation with dc gives
>   2^32-1 as 18446744073709551615                   ~(long)0
>   2^31-1 as 9223372036854775807                   (~(long)0) >> 1
> ]
> 
> --

You are of course correct. The one is arguably an error in that
the compiler follows K&R by default instead of the current 
ansi standards.  The other is a bonehead oversight on my part.
Mea Culpa!! (-:

Charlie

 *************************************************************************
 *  Charles Richmond 	Integrated International Systems Corporation     *
 *	  cmr@iisc.com	cmr@koibito.iisc.com  cmr@shore.net		 *
 *  UNIX Internals, I18N, L10N, X, Realtime Imaging, and  Custom S/W	 *
 *  One Longfellow Place Suite 3309 , Boston , Ma. USA 02114-2431        *
 *  (617) 723 7695	(617) 367 3151		FAX (617) 723 6861       *
 *************************************************************************



  reply	other threads:[~1996-07-23  4:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-20  4:00 cc bugs? philips
1996-07-22  4:00 ` Joe Mario
     [not found]   ` <31F4A4BE.6201@iisc.com>
1996-07-23  4:00     ` Stephen Baynes
1996-07-23  4:00       ` Charles M Richmond [this message]
1996-07-25  4:00         ` Dan Pop
1996-07-22  4:00 ` Stephen Baynes
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox