[using gcc book] 5.25 declaring attributes of functions

Bernardo Innocenti bernie@develer.com
Sun Aug 24 17:46:00 GMT 2003


On Sunday 24 August 2003 04:42, Chris Devers wrote:
> In the discussion of the 'const' attribute, we have this paragraph:
>
>     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 above, since function is not allowed to
>     read global memory.
>
> That second sentence reads clumsily. I'm thinking of this change:
>
>     Many functions do not examine any values except their
>     arguments, and have no effects except the return value.
>     This case is slightly more strict than the @code{pure}
>     attribute above, since the function is not allowed to read
>     global memory.
>
> Any objections to this change?

I certainly appreciate this change since I've misunderstood the
original text and incorrectly used attribute((const)) in a
function that looked like this:

  uint32_t do_div(uint64_t *base, uint32_t rem);


The term "global" memory got me confused. It might be worth
mentioning that it means all memory except local variables
on the stack.

-- 
  // Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/  http://www.develer.com/

Please don't send Word attachments - http://www.gnu.org/philosophy/no-word-attachments.html




More information about the Gcc mailing list