This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/81679] use attribute unused on function arguments as an optimization hint
- From: "joseph at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 02 Aug 2017 22:18:14 +0000
- Subject: [Bug tree-optimization/81679] use attribute unused on function arguments as an optimization hint
- Auto-submitted: auto-generated
- References: <bug-81679-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81679
--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Wed, 2 Aug 2017, msebor at gcc dot gnu.org wrote:
> 1) When attribute unused is specified on a function argument of pointer type in
> a declaration of a function, GCC could use that as an indication that the
> argument is, in fact, not used by the implementation of the function and assume
> that the object the pointer points to is unchanged by the function call.
It's peculiar to use the attribute on an argument in a declaration that's
not a definition, but in definitions it very definitely means *may be
unused* - for example, the attribute may be present unconditionally for a
function where the argument might or might not be used, depending on
various preprocessor conditionals, to avoid needing to replicate those
conditionals when declaring the argument. So this would not be a valid
optimization.