From: | jmccarty@sun1307.spd.dsccc.com (Mike McCarty) |
Newsgroups: | comp.compilers |
Date: | 2 Apr 1996 23:49:23 -0500 |
Organization: | DSC Communications Corporation |
References: | 96-03-106 96-03-181 96-03-202 |
Keywords: | C, optimize, performance |
)> However, I agree with you on the "const" feature -- but for different
)> reasons. Not only should the compilers be using the "const" feature,
)> but it shouldn't even have to have it because it should already be
)> doing expression evaluations to reduce all those expressions that can
)> be reduced at compile-time.
)>
)> In the example you cite:
)> > #define ONE 1
)> > const int one = 1;
)> >
)> > int f()
)> > {
)> > x = ONE;
)> > y = one;
)> > }
)>
)> this should compile to exactly the same thing as the following does:
)>
)> int f() { x = 1; y = 1; }
Christopher Glaeser <cdg@nullstone.com> wrote:
)Yes, that's precisely the point. There's no disagreement here.
This in reply to what Christopher seems to be saying. In my mind, the
real reason for "const" to exist in C has nothing to do with the
conversation you are having. It has to do with pointers used as
arguments to routines which must read the areas pointed to, but which
are not intended to modify them. As in:
char *strcpy(char *dest,const char *source);
Mike
--
----
char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.