https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99611
Bug ID: 99611 Summary: Code compilation issue using templates Product: gcc Version: 9.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: asif_bahrainwala at hotmail dot com Target Milestone: --- Hi, a minimalist re-pro is available at https://stackoverflow.com/questions/66641646/c-code-compilation-usage-of-fstream-ostream The below code compiles in Clang but not in GCC (and VS2015): #include <iostream> #include <fstream> using namespace std; struct A { int z=0; template<typename T> void func(T &y) { //cout<<typeid(T).name()<<endl; y<<z<<endl; } }; template<typename T,typename T1> T& operator<<(T &y,T1 &y1) { y1.func(y); return y; } int main() { A a; a.z=10; fstream fs("a.txt",ios::out); fs<<a; //this doesnt compile ???? ( I do have a walk around, but curious) cout<<a; //this works return 0; }