Subject: Re: example for k&r being bad (was: Re: Bluetooth protocol code)
To: Hubert Feyrer <feyrer@cs.stevens.edu>
From: David Brownlee <abs@NetBSD.org>
List: tech-userlevel
Date: 12/20/2005 08:19:14
On Tue, 20 Dec 2005, Hubert Feyrer wrote:

> On Tue, 20 Dec 2005, der Mouse wrote:
>> int pr(x,y)
>> long int x;
>> int y;
>> {
>> printf("%ld %d\n",x,y);
>> }
>> 
>> int main(ac,av)
>> int ac;
>> char **av;
>> {
>> pr(1,2);
>> return(0);
>> }
>> 
>> Under IL32 or IL64 (actually, when int and long are the same as far as
>> argument passing goes), this "works"; when long occupies more
>> argument-list space than int, you get brokenness - probably either
>> 4294967298 or 8589934593, followed by a "random" value that generally
>> comes from uninitialized stack trash.
>
> output on i386:  1 2
> output on alpha: 1 2

 	Try it on a big endian LP64 such as sparc64. sparc64 is wonderful
 	for picking up portability from x86 issues...
-- 
 		David/absolute       -- www.NetBSD.org: No hype required --