[Bug c++/95484] New: Friend declaration of member function template has no effect
herring at lanl dot gov
gcc-bugzilla@gcc.gnu.org
Tue Jun 2 18:21:18 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95484
Bug ID: 95484
Summary: Friend declaration of member function template has no
effect
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: herring at lanl dot gov
Target Milestone: ---
The current build at Compiler Explorer rejects
struct A {
template<class T> operator T*() const;
};
class B {
constexpr static decltype(nullptr) null=nullptr;
template<class T> friend A::operator T*() const;
};
template<class T> A::operator T*() const {return B::null;}
int main() {
int *p=A();
return !!p;
}
with
<source>: In instantiation of 'A::operator T*() const [with T = int]':
<source>:13:12: required from here
<source>:10:53: error: 'constexprstd::nullptr_t B::null' is private within
this context
10 | template<class T> A::operator T*() const {return B::null;}
| ~~~^~~~
<source>:6:38: note: declared private here
6 | constexpr static decltype(nullptr) null=nullptr;
| ^~~~
(Note also the missing space in the restated declaration of B::null.)
Declaration matching has certainly succeeded: omitting the 'const' from the
friend declaration or changing "T*" to "T**", "T", or "T&" produces a (correct)
error about the member function template not being found.
More information about the Gcc-bugs
mailing list