This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: function attribute const
On Mar 13, 2002, Tony Finch <dot@dotat.at> wrote:
> On Wed, Mar 13, 2002 at 03:38:36PM +0100, Jan Hubicka wrote:
>> >
>> > If the programmer knows that the data structures which a function
>> > examines will not change from one invocation of the function to
>> > another, why can't the function be declared const?
>>
>> Compiler may want to move the function call around and may get it before
>> the structure is initialized.
> I can make sure that a valid pointer implies that what is pointed to has
> been initialized.
But you also have to make sure the compiler won't move the
initialization past the call of the const function.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer