On 11/25/18 6:40 PM, Sandra Loosemore wrote:
I've checked in the attached patch for PR79738.

I think we have lost something important with the clarification
of attribute const:

  The @code{const} attribute imposes greater restrictions on
  a function's definition than the similar @code{pure} attribute
  below because it additionally prohibits the function from reading
  memory except for constant global variables.

Permitting a const function to only read global constants means
it can't read local variables (including static const locals).
Something like the following should fix that:

  The @code{const} attribute prohibits a function from accessing
  objects whose value can change between successive invocations of
  the function.  Functions declared with the @code{const} attribute
  may access non-volatile constant objects with any storage duration.
  The attribute imposes greater restrictions on a function's definition
  than the similar @code{pure} attribute.

I have also removed the mention of global variables (since objects
at other scopes, including static locals or thread-local variables,
are also included) and instead of "reading" used the term "accessing"
since const functions can neither read nor write such objects.
 Finally, I've avoided describing the attribute in terms of pure
("additionally") and instead only mentioned pure for reference.

Let me know how this sounds.

Martin

Reply via email to