Index: clang/include/clang/AST/ASTUnresolvedSet.h =================================================================== --- clang/include/clang/AST/ASTUnresolvedSet.h +++ clang/include/clang/AST/ASTUnresolvedSet.h @@ -69,7 +69,12 @@ return false; } - void erase(unsigned I) { Decls[I] = Decls.pop_back_val(); } + void erase(unsigned I) { + if (I == Decls.size() - 1) + Decls.pop_back(); + else + Decls[I] = Decls.pop_back_val(); + } void clear() { Decls.clear(); } Index: clang/test/SemaCXX/using-decl-templates.cpp =================================================================== --- clang/test/SemaCXX/using-decl-templates.cpp +++ clang/test/SemaCXX/using-decl-templates.cpp @@ -102,6 +102,28 @@ }; } // namespace DontDiagnoseInvalidTest +namespace shadow_nested_operator { + template + struct A { + struct Nested {}; + operator Nested*() {return 0;}; + }; + + template + struct B : A { + using A::operator typename A::Nested*; + operator typename A::Nested *() { + struct A * thi = this; + return *thi; + }; + }; + + int foo () { + struct B b; + auto s = *b; + } +} // namespace shadow_nested_operator + namespace func_templ { namespace sss { double foo(int, double);