enum function bug?

Colin Kelley colin at vu-vlsi.UUCP
Wed Sep 24 03:04:06 AEST 1986


In article <103 at hcx1.UUCP> notes at hcx1.UUCP writes:
>
>struct st { int c ; } ; 
>int func (b);
>   int b; 
>{
>}
>main()
>{
>   struct st s;
>   func (&s);
>}
This is obviously wrong, since ints are not pointers!  But what I thought
you were going to try was

main()
{
	struct st s;
	func (s);
}

That is, call func() passing it the whole structure as if it were an int,
since we all _know_ the structure just consists of one int anyway, right!
PLEASE DON'T DO THIS!!!  Of course it won't get by lint, but quite a few
programmers wind up doing it because it works on so many machines.  Well,
it doesn't work at all on a Pyramid, where structures are passed differently
than ints.

Someone here got bitten by this attempting to port smp (a symbolic math
package) to our Pyramid.  The bozo programmer had declared a union containing
all possible pointers, but then declared the formal parameter just as a pointer
to an int.  "What", you say, "commercial code which doesn't even pass lint?"
That's what I said too!  Yuck...

			-Colin Kelley ..{cbmvax,pyrnj,psuvax1}!vu-vlsi!colin



More information about the Comp.lang.c mailing list