[Bug c++/96498] Wrong location for function first declared as a friend in a template
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Aug 6 13:42:02 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96498
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2020-08-06
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This happens even if the function has already been declared at namespace scope
prior to the friend declaration in the class template:
__attribute__((nonnull(1))) void foo(void*);
template<typename>
struct T {
friend void foo(void*);
};
void bar()
{
foo(0);
T<int> t;
foo(0);
}
attr.C: In function 'void bar()':
attr.C:11:8: warning: argument 1 null where non-null expected [-Wnonnull]
11 | foo(0);
| ^
attr.C:1:34: note: in a call to function 'void foo(void*)' declared 'nonnull'
1 | __attribute__((nonnull(1))) void foo(void*);
| ^~~
attr.C:13:8: warning: argument 1 null where non-null expected [-Wnonnull]
13 | foo(0);
| ^
attr.C:5:15: note: in a call to function 'void foo(void*)' declared 'nonnull'
5 | friend void foo(void*);
| ^~~
attr.C:12:10: warning: unused variable 't' [-Wunused-variable]
12 | T<int> t;
| ^
I think the friend in the template should not change anything here, since the
function is already visible.
More information about the Gcc-bugs
mailing list