https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81679
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=81009
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Right, the attribute would imply a stronger guarantee on a declaration than on
a definition.
If there is a concern that the attribute could be used on declarations in
existing code that the optimization might break, then the attribute could be
specified differently (e.g., as a function attribute with an argument number
indicating which argument is unused; that would also differentiate it from the
existing function attribute). Or the same feature could be provided under a
different attribute. The main idea here is the ability to express the notion
that a function doesn't modify an object via its (non-const) pointer argument.
The name for the feature is secondary (though "unused" is obviously a nice
fit).
For const pointer arguments, pr81009 points out another opportunity to rely on
restrict for a similar guarantee (i.e., read-only access to the object).