Broken compilers (Was Portability of passing/operating on structures)

Knudsen knudsen at ihlpl.ATT.COM
Tue Oct 25 04:46:15 AEST 1988


In article <73946 at sun.uucp>, jamesa%betelgeuse at Sun.COM (James D. Allen) writes:

> 	struct {
> 		whatever;
> 	} st;
> 	/* the next will be treated as though it were "foo(&st);"  */
> 		foo(st);
This is my main objection to structure and array assignment and
passing.  Aside from being hideously wasteful of time and stack space,
they permit common typo errors (omission of &) to go undetected.

> [more code example] 
> (I think this arose because a little-Endian compiler was ported to a
>  big-Endian machine without ample thought and/or testing.)

Big-Endian (walkie-talkie company) micros also pose an interesting
problem in casting an (int *) to a (char *); to do this right
the compiler should add 1, but does not.  No problem once you
realize it -- after all, C is structured assembler, eh?

Actually I like the semantics that casting any pointer to (char *)
means "keep the numerical address value the same."
-- 
Mike Knudsen  Bell Labs(AT&T)   att!ihlpl!knudsen
"Lawyers are like handguns and nuclear bombs.  Nobody likes them,
but the other guy's got one, so I better get one too."



More information about the Comp.lang.c mailing list