http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58022
--- Comment #3 from Ryan Johnson <scovich at gmail dot com> --- (In reply to Paolo Carlini from comment #1) > Please try to reduce the testcase further, no includes. You have a number of > options here: http://gcc.gnu.org/wiki/A_guide_to_testcase_reduction Sorry, I thought <ostream> was an important part of the bug and did some work to put it back in... Here's the fully reduced case: // <<<--- begin bug.cpp --->>> template<typename _CharT> class basic_ostream; typedef basic_ostream<char> ostream; template<typename T> basic_ostream<T>& operator<<(basic_ostream<T>&, T); template <class T> class foo; template <class T> ostream & operator<<(ostream&, const foo<T>&); template <class T> class foo { friend ostream& operator<< <T> (ostream&, const foo<T>&); }; class bar; foo<bar> fb; class bar { virtual void baz()=0; }; // <<<--- end bug.cpp --->>>