------- Additional Comments From rakdver at atrey dot karlin dot mff dot cuni dot cz 2005-05-22 20:01 ------- Subject: Re: missed optimization due with const function and pulling out of loops
> <quote>const > Many functions do not examine any values except their arguments, and have > no > effects except the return value. Basically this is just slightly more strict > class than the pure attribute below, since function is not allowed to read > global memory.</quote> > > So get_type2() should not use any global table. Right ? this depends on interpretation of this definition. Some people want this to read "behaves as if" and thus allow for example caching of the results of such function. For more discussion see PR19828. Nevertheless, even if we are very strict with the definition, moving get_type2 out of the loop is not a good idea, since get_type2 might potentially be very expensive (and we have no way how to determine that this is not the case), thus we would lose in case get_type2 should be never executed. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21712