https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96516
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org Last reconfirmed| |2020-08-07 Status|UNCONFIRMED |NEW Ever confirmed|0 |1 --- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> --- I think the C++ front end needs to hold off applying the copy attribute until the template it's on is instantiated. This is hardcoded for other attributes but not for copy, so it won't work very well with templates. This doesn't work correctly either (although probably for a different reason): template <class T> __attribute__((returns_nonnull)) T foo () { return T (); } __attribute__((copy (foo<void*>))) void* bar () { return 0; } t.C:4:47: warning: ‘copy’ attribute ignored on a declaration of a different kind than referenced symbol [-Wattributes] 4 | __attribute__((copy (foo<void*>))) void* bar () { return 0; } | ^