This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: why are we not using const?


 > Notice that the value of the parameter "b" is never changed in the
 > function body.  Consequently, if the current optimizers cannot figure
 > that simple cases out (where "b" is not annotated const), then the
 > optimizers in deficient in that respect.  That is the point.
 > -- Gaby

I agree that the compiler should/could be better at optimizing.

However my feeling is that 'const' is more important as documentation
and enforcement of APIs rather than an optimization hint.  From this
perspective, what "b" points to not getting changed is more important
to the caller than whether the function body changes the value of "b"
itself, since the caller doesn't see the latter.

I'd like to do for tree and rtx what I did for const char *, namely
constify those tree/rtx functions that aren't supposed to modify their
arguments.  This would require introducing the const_tree and
const_rtx typedefs Tristan suggested.

Something for stage1, obviously.

		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]