Hi! I'm trying to understand why those two attributes exist.
const
Calls to functions whose
return value is not affected
by changes to the observable state of the program
and that
have no observable effects on such state
other than to return a value
may lend themselves to optimizations such as common
subexpression elimination.
pure
Calls to functions that
have no observable effects on the state of the program
other than to return a value
may lend themselves to optimizations such as common
subexpression elimination.
The difference seems to be only that pure functions can read memory
through pointers. However, that is already obvious information from the
prototype. That is, the following function would be implicitly const,
by being pure and not having pointer arguments, right?
int square(int) __attribute__((pure));
Do we really need a separate attribute?
Have a lovely night!
Alex
--
<https://www.alejandro-colomar.es>
signature.asc
Description: PGP signature
