Article View: net.lang.c
Article #9373Re: enum function bug?
From: Colin Kelley
Date: Tue, 23 Sep 1986 17:04
Date: Tue, 23 Sep 1986 17:04
35 lines
1617 bytes
1617 bytes
In article <103@hcx1.UUCP> notes@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
Technical Details
Message-ID:
<365@vu-vlsi.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!caip!cbmvax!vu-vlsi!colinReferences:
<103@hcx1.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!caip!cbmvax!vu-vlsi!colin From: colin@vu-vlsi.UUCP (Colin Kelley) Newsgroups: net.lang.c Subject: Re: enum function bug? Message-ID: <365@vu-vlsi.UUCP> Date: Tue, 23-Sep-86 13:04:06 EDT Article-I.D.: vu-vlsi.365 Posted: Tue Sep 23 13:04:06 1986 Date-Received: Tue, 23-Sep-86 23:05:05 EDT References: <103@hcx1.UUCP> Reply-To: colin@vu-vlsi.UUCP (Colin Kelley) Organization: Villanova Univ. EE Dept. Lines: 35