Re: const versus __attribute__((const))

Nikita Danilov
2003-12-08T18:27:21Z

H. Peter Anvin writes:
> Arnd Bergmann wrote:
> > H. Peter Anvin writes:
> >
> >>I have made a patch against the current tree defining
> >>__attribute_const__ in <linux/compiler.h> and using it in the above
> >>cases; does anyone know any reason why I should *NOT* submit this to
> >>Linus?
> >
> >
> > I noticed before that gcc appearantly ignores __attribute__((const))
> > for inline functions, so both the original and your proposed code
> > is rather pointless as an optimization, except for extern declarations.
> >
> > I'd rather remove the 'const' completely where it causes warnings for
> > inline functions.
> >
>
> These functions are available to userspace, though, and can be compiled
> with -O0; thus not inlined.

And future versions of gcc can be smarter.

>
> -hpa

Nikita.