Re: const and static (was: C vs. assembly...)

jmccarty@sun1307.spd.dsccc.com (Mike McCarty)
2 Apr 1996 23:49:23 -0500

          From comp.compilers

Related articles
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? cdg@nullstone.com (1996-03-16)
const and static (was: C vs. assembly...) mark@omnifest.uwm.edu (1996-03-25)
const and static (was: C vs. assembly...) fjh@cs.mu.OZ.AU (1996-03-27)
Re: const and static (was: C vs. assembly...) cdg@nullstone.com (1996-03-27)
Re: const and static (was: C vs. assembly...) mason@ease.com (1996-03-29)
Re: const and static (was: C vs. assembly...) cdg@nullstone.com (1996-04-02)
Re: const and static (was: C vs. assembly...) jmccarty@sun1307.spd.dsccc.com (1996-04-02)
Re: const and static (was: C vs. assembly...) KingD@rnd1.indy.tce.com (King Dale) (1996-04-11)
Re: const and static (was: C vs. assembly...) cdg@nullstone.com (1996-04-12)
Re: const and static (was: C vs. assembly...) cdg@nullstone.com (1996-04-12)
Re: const and static (was: C vs. assembly...) sharris@fox.nstn.ca (1996-04-13)
Re: const and static (was: C vs. assembly...) mfinney@inmind.com (1996-04-16)
Re: const and static (was: C vs. assembly...) schwarz@mips.complang.tuwien.ac.at (1996-04-18)
| List of all articles for this month |
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);}
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.