Path: utzoo!yunexus!geac!syntron!jtsv16!uunet!seismo!sundc!pitstop!sun!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: Broken compilers (Was Portability of passing/operating on structures) Message-ID: <570@quintus.UUCP> Date: 25 Oct 88 09:43:57 GMT Article-I.D.: quintus.570 References: <8810111934.AA21941@ucbarpa.Berkeley.EDU> <8308@alice.UUCP> <73946@sun.uucp> <7356@ihlpl.ATT.COM> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 28 In article <7356@ihlpl.ATT.COM> knudsen@ihlpl.ATT.COM (Knudsen) writes: >In article <73946@sun.uucp>, jamesa%betelgeuse@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!).