Newsgroups: comp.lang.c
Path: utzoo!henry
From: henry@utzoo.uucp (Henry Spencer)
Subject: Re: "Numerical Recipes in C" is nonportable code
Message-ID: <1988Sep17.210915.8655@utzoo.uucp>
Organization: U of Toronto Zoology
References: <664@lindy.Stanford.EDU> <6758@megaron.arizona.edu> <718@gtx.com> <640@drilex.UUCP> <1429@ficc.uu.net> <8470@smoke.ARPA> <5514@eagle.ukc.ac.uk>
Date: Sat, 17 Sep 88 21:09:15 GMT

In article <5514@eagle.ukc.ac.uk> mtr@arthur.UUCP (M.T.Russell) writes:
>	union foo {
>		char *data;
>		int (*func)();
>	};
>
>The compiler would either have to prohibit unions with both text and
>data pointers or do runtime bookkeeping to remember what was last
>stored in such unions.

No, it is sufficient if any attempt to use this trick malfunctions badly.
(For example, if the two kinds of pointers are not the same size, it is
almost guaranteed to.)
-- 
NASA is into artificial        |     Henry Spencer at U of Toronto Zoology
stupidity.  - Jerry Pournelle  | uunet!attcan!utzoo!henry henry@zoo.toronto.edu
