https://bugs.llvm.org/show_bug.cgi?id=43358

            Bug ID: 43358
           Summary: c++ parser crash on invalid code
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: unassignedclangb...@nondot.org
          Reporter: emmanuel.th...@inria.fr
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

Created attachment 22526
  --> https://bugs.llvm.org/attachment.cgi?id=22526&action=edit
complete source code

clang++ 8.0.1-3+b1 encounters a c++ crash on the attached code. I acknowledge
the fact that the code is invalid, but a parser crash should not occur.

Test source file, output, and reproducer attached.

template<bool happy>
struct pool {
    bool ok() const { return happy; }
    template<typename T> struct proxy {
        bool ok() { return T::f.ok(); }
    };
};
template<bool b> class obj {
    typedef pool<b> pool_t;
    static pool_t f;
public:
    typedef typename pool_t::template proxy<obj> proxy_t;
    template<> friend struct pool_t::proxy<obj>;  // ***parser crash***
};
extern template class obj<true>;
int main()
{
    obj<true>::proxy_t dummy;
    return dummy.ok();
}

Here's a small bit of the full stack trace

#4 0x00000000016e777e
clang::Sema::MatchTemplateParametersToScopeSpecifier(clang::SourceLocation,
clang::SourceLocation, clang::CXXScopeSpec const&,
clang::TemplateIdAnnotation*,
llvm::ArrayRef<clang::TemplateParameterList*>, bool, bool&, bool&)
(/usr/lib/llvm-8/bin/clang+0x16e777e)
#5 0x00000000016fb471
clang::Sema::ActOnClassTemplateSpecialization(clang::Scope*, unsigned
int, clang::Sema::TagUseKind, clang::SourceLocation, clang::SourceLocation,
clang::TemplateIdAnnotation&, clang::ParsedAttributesView const&,
llvm::MutableArrayRef<clang::TemplateParameterList*>,
clang::Sema::SkipBodyInfo*)
(/usr/lib/llvm-8/bin/clang+0x16fb471)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to