[Bug c++/53403] New: Function template friend denied access to private types of granting template class.
ibugs at qult dot net
gcc-bugzilla@gcc.gnu.org
Fri May 18 17:48:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53403
Bug #: 53403
Summary: Function template friend denied access to private
types of granting template class.
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: ibugs@qult.net
The following code compiles with GCC 4.4 but not since 4.5, until at least
4.7.0.
template <typename T>
class Foo {
typedef void type;
template <typename U> friend void f();
public:
Foo() {}
};
template class Foo<void>;
template <typename T>
void f()
{
typedef Foo<void>::type type;
}
int main()
{
f<void>();
}
If the function template is declared before the definition of the class
template, or if the Foo<void> class is instantiated after f's definition, the
code compiles. The error appears only with private types, not other private
members.
Easy to work around, but still... :/
More information about the Gcc-bugs
mailing list