Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site rlgvax.UUCP
Path: utzoo!linus!philabs!cmcl2!seismo!rlgvax!guy
From: guy@rlgvax.UUCP (Guy Harris)
Newsgroups: net.lang.c
Subject: Re: storage class "private"
Message-ID: <158@rlgvax.UUCP>
Date: Sun, 30-Sep-84 03:20:33 EDT
Article-I.D.: rlgvax.158
Posted: Sun Sep 30 03:20:33 1984
Date-Received: Tue, 2-Oct-84 03:31:50 EDT
References: <156@rlgvax.UUCP> <15991@arizona.UUCP>
Organization: CCI Office Systems Group, Reston, VA
Lines: 37

> (In reference to Guy Harris' contention that a C compiler can't prohibit you
> from taking the address of a variable declared "private")
> 
> A C compiler most certainly can!  Try taking the address of a register
> variable.

What I should have said was that the compiler can't prevent you from
stuffing some address that points to that variable into a pointer; the
the person I was replying to was saying that "private" wouldn't work in
C because the declaring something as "private" doesn't 100% guarantee
that nothing can ever point to it.  That is true, but not particularly
relevant; optimization could reveal bugs (or even cover them up!) by
referencing a copy of a variable which changed out from under the copy,
but that's not the fault of the optimizer.

> Why, oh why, don't C compilers optimize?  I am tired of hacking source
> in order to get the code I know I want -- the technology certainly
> exists to let the compiler do most of that work for me.  An example 
> is using a pointer variable instead of array indexing in a 'for' loop --
> for maximum efficiency, I have to write:
> 	{ struct foo *foop = fooarr;
> 	  for (i=0, i < FOOMAX; i++)
> 		dostuff(*(foop++));
> 	}
> instead of what I mean:
> 	for (i=0; i < FOOMAX; i++)
> 		dostuff(fooarr[i]);

Amen!  There do exist optimizing C compilers, but unfortunately PCC, upon
which most UNIX C compilers seem to be based, isn't one of them.  (I first
saw the particular strength reduction you mention in, of all places, the
DEC PDP-11 threaded code FORTRAN compiler; it showed up because somebody
had written a threaded code to pseudo-C decompiler and ran it on "adventure",
and it produced that sort of *p++ code.)

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy