The code below won't compile. It behaves as though the line class val<T> { friend class rec; } is erroneously declaring a 'struct rec' in the global namespace. (Uncomment the other use of rec to see this.) The error message from 4.0 is: y.cpp: In function 'int main(int, char**)': y.cpp:29: error: 'rec' was not declared in this scope y.cpp:29: error: expected `;' before 'r'
This shows up on 3.4.3, 3.4.4 and 4.0. David namespace ns { template<typename T> class val { T get(const unsigned char *data) const; public: friend class rec; // see 7.3.1.2 val<T>() { } }; template<> inline float val<float>::get(const unsigned char *data) const { return *reinterpret_cast<const float *>(data); } class rec { public: const unsigned char *data; }; } using namespace ns; int main(int argc, char **argv) { rec r; // ::rec s; return 0; } -- Summary: friend class declaration in namespace wrong in template class with specialisation Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: drtr at dial dot pipex dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20996