------- Comment #4 from jwakely dot gcc at gmail dot com 2009-08-12 09:41 ------- I think maybe the second example is rejected because of 2) not 3)
2) A name N used in a class S shall refer to the same declaration in its context and when re-evaluated in the completed scope of S. No diagnostic is required for a violation of this rule. 'foo' is used in the class, but in the completed scope which includes the function body of S::foo() 'foo' refers to the member function. If you don't want to use -fpermissive you can convince gcc to compile it by referring to the type as '::foo' because in that case the name always refers to the global type even in the completed scope. struct foo { }; struct bar { ::foo foo(); }; -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41039