Broken compilers (Was Portability of passing/operating on structures)
Richard A. O'Keefe
ok at quintus.uucp
Tue Oct 25 19:43:57 AEST 1988
In article <7356 at ihlpl.ATT.COM> knudsen at ihlpl.ATT.COM (Knudsen) writes:
>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);
I've been using C since version 6+, and I've never seen a compiler that
did that. structs and unions have been passed by value since UNIX V7.
>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.
(a) hideously wasteful of time and stack space compared to WHAT?
No-one is forcing you to pass structs by value if you don't want to.
And if x and y are struct variables,
x = y;
should be at least as fast as anything you could have written to do
the same job. C hasn't got array assignment, otherwise the same
remark would apply. (struct assignment typically takes NO stack space.)
(b) cc is half a compiler. The other half is called lint. There has never
been any reason why a C compiler couldn't give you a warning message
when a call disagreed with a function definition in the same file; I've
met a UNIX C compiler that did it (viva Orion!).
More information about the Comp.lang.c
mailing list