<div dir="ltr">Thanks, filed as <a href="https://llvm.org/PR37008">https://llvm.org/PR37008</a></div><div class="gmail_extra"><br><div class="gmail_quote">On 3 April 2018 at 19:33, Jim Meyering via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
[As with yesterday's report, I would have used your <a href="http://bugs.llvm.org" rel="noreferrer" target="_blank">bugs.llvm.org</a><br>
bug-reporting form, but have no account and still have not heard back<br>
from <a href="mailto:bugs-admin@lists.llvm.org">bugs-admin@lists.llvm.org</a> regarding my registration request]<br>
<br>
This was a bit tricky even to find/reduce with a default clang build,<br>
but once I built clang itself with ASAN, it's obvious and consistently<br>
reproducible -- alternatively, set e.g., MALLOC_DEBUG_=45 (or any other<br>
value in 1..255) to make it more consistently reproducible with the<br>
non-ASAN binary.<br>
<br>
Here's the minimized reproducer:<br>
<br>
  printf 'template <int> void ngX() template z()->ngY<>;' | clang -cc1 -x c++<br>
<br>
Here's most of the resulting output:<br>
<br>
<stdin>:1:26: error: expected ';' at end of declaration<br>
template <int> void ngX() template z()->ngY<>;<br>
                         ^<br>
                         ;<br>
<stdin>:1:41: error: no template named 'ngY'; did you mean 'ngX'?<br>
template <int> void ngX() template z()->ngY<>;<br>
                                        ^~~<br>
                                        ngX<br>
<stdin>:1:21: note: 'ngX' declared here<br>
template <int> void ngX() template z()->ngY<>;<br>
                    ^<br>
<stdin>:1:41: error: expected a type<br>
template <int> void ngX() template z()->ngY<>;<br>
                                        ^<br>
<stdin>:1:41: error: variable cannot be defined in an explicit instantiation; if this declaration is meant to be a variable definition, remove the 'template' keyword<br>
template <int> void ngX() template z()->ngY<>;<br>
                          ~~~~~~~~~     ^<br>
<stdin>:1:36: error: C++ requires a type specifier for all declarations<br>
template <int> void ngX() template z()->ngY<>;<br>
                                   ^<br>
<stdin>:1:45: error: expected ';' at end of declaration<br>
template <int> void ngX() template z()->ngY<>;<br>
                                            ^<br>
                                            ;<br>
==============================<wbr>==============================<wbr>=====<br>
==3876978==ERROR: AddressSanitizer: heap-use-after-free on address 0x607000001a30 at pc 0x000005a27670 bp 0x7ffd8a754350 sp 0x7ffd8a754348<br>
READ of size 4 at 0x607000001a30 thread T0<br>
    #0 0x5a2766f in clang::Parser::<wbr>ParseDeclarationSpecifiers(<wbr>clang::DeclSpec&, clang::Parser::<wbr>ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::<wbr>DeclSpecContext, clang::Parser::<wbr>LateParsedAttrList*) /tmp/llvm/tools/clang/lib/<wbr>Parse/ParseDecl.cpp:3310<br>
    #1 0x59f70e3 in clang::Parser::<wbr>ParseDeclOrFunctionDefInternal<wbr>(clang::Parser::<wbr>ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /tmp/llvm/tools/clang/lib/<wbr>Parse/Parser.cpp:922<br>
    #2 0x59f6b86 in clang::Parser::<wbr>ParseDeclarationOrFunctionDefi<wbr>nition(clang::Parser::<wbr>ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /tmp/llvm/tools/clang/lib/<wbr>Parse/Parser.cpp:1028<br>
    #3 0x59f56f2 in clang::Parser::<wbr>ParseExternalDeclaration(<wbr>clang::Parser::<wbr>ParsedAttributesWithRange&, clang::ParsingDeclSpec*) /tmp/llvm/tools/clang/lib/<wbr>Parse/Parser.cpp:853<br>
    #4 0x59f45d1 in clang::Parser::<wbr>ParseTopLevelDecl(clang::<wbr>OpaquePtr<clang::DeclGroupRef><wbr>&) /tmp/llvm/tools/clang/lib/<wbr>Parse/Parser.cpp:609<br>
    #5 0x59ee6bb in clang::ParseAST(clang::Sema&, bool, bool) /tmp/llvm/tools/clang/lib/<wbr>Parse/ParseAST.cpp:152<br>
    #6 0x3c95c64 in clang::FrontendAction::<wbr>Execute() /tmp/llvm/tools/clang/lib/<wbr>Frontend/FrontendAction.cpp:<wbr>904<br>
    #7 0x3c03f86 in clang::CompilerInstance::<wbr>ExecuteAction(clang::<wbr>FrontendAction&) /tmp/llvm/tools/clang/lib/<wbr>Frontend/CompilerInstance.cpp:<wbr>989<br>
    #8 0x3e0bf27 in clang::<wbr>ExecuteCompilerInvocation(<wbr>clang::CompilerInstance*) /tmp/llvm/tools/clang/lib/<wbr>FrontendTool/<wbr>ExecuteCompilerInvocation.cpp:<wbr>255<br>
    #9 0xf90faf in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /tmp/llvm/tools/clang/tools/<wbr>driver/cc1_main.cpp:221<br>
    #10 0xf818e9 in ExecuteCC1Tool(llvm::ArrayRef<<wbr>char const*>, llvm::StringRef) /tmp/llvm/tools/clang/tools/<wbr>driver/driver.cpp:310<br>
    #11 0xf81581 in main /tmp/llvm/tools/clang/tools/<wbr>driver/driver.cpp:390<br>
    #12 0x7f6051da4c04 in __libc_start_main ??:?<br>
    #13 0xe5fe33 in _start ??:?<br>
<br>
0x607000001a30 is located 64 bytes inside of 80-byte region [0x6070000019f0,<wbr>0x607000001a40)<br>
freed by thread T0 here:<br>
    #0 0xf372c0 in __interceptor_free.localalias.<wbr>0 crtstuff.c:?<br>
    #1 0x59feac7 in ~<wbr>DestroyTemplateIdAnnotationsRA<wbr>IIObj /tmp/llvm/build/../tools/<wbr>clang/include/clang/Parse/<wbr>RAIIObjectsForParser.h:459<br>
    #2 0x59f580d in clang::Parser::<wbr>ParseExternalDeclaration(<wbr>clang::Parser::<wbr>ParsedAttributesWithRange&, clang::ParsingDeclSpec*) /tmp/llvm/tools/clang/lib/<wbr>Parse/Parser.cpp:859<br>
    #3 0x59f45d1 in clang::Parser::<wbr>ParseTopLevelDecl(clang::<wbr>OpaquePtr<clang::DeclGroupRef><wbr>&) /tmp/llvm/tools/clang/lib/<wbr>Parse/Parser.cpp:609<br>
    #4 0x59ee6bb in clang::ParseAST(clang::Sema&, bool, bool) /tmp/llvm/tools/clang/lib/<wbr>Parse/ParseAST.cpp:152<br>
    #5 0x3c95c64 in clang::FrontendAction::<wbr>Execute() /tmp/llvm/tools/clang/lib/<wbr>Frontend/FrontendAction.cpp:<wbr>904<br>
    #6 0x3c03f86 in clang::CompilerInstance::<wbr>ExecuteAction(clang::<wbr>FrontendAction&) /tmp/llvm/tools/clang/lib/<wbr>Frontend/CompilerInstance.cpp:<wbr>989<br>
    #7 0x3e0bf27 in clang::<wbr>ExecuteCompilerInvocation(<wbr>clang::CompilerInstance*) /tmp/llvm/tools/clang/lib/<wbr>FrontendTool/<wbr>ExecuteCompilerInvocation.cpp:<wbr>255<br>
    #8 0xf90faf in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /tmp/llvm/tools/clang/tools/<wbr>driver/cc1_main.cpp:221<br>
    #9 0xf818e9 in ExecuteCC1Tool(llvm::ArrayRef<<wbr>char const*>, llvm::StringRef) /tmp/llvm/tools/clang/tools/<wbr>driver/driver.cpp:310<br>
    #10 0xf81581 in main /tmp/llvm/tools/clang/tools/<wbr>driver/driver.cpp:390<br>
    #11 0x7f6051da4c04 in __libc_start_main ??:?<br>
<br>
previously allocated by thread T0 here:<br>
    #0 0xf374d0 in __interceptor_malloc ??:?<br>
    #1 0xfb2b0a in llvm::safe_malloc(unsigned long) /tmp/llvm/build/../include/<wbr>llvm/Support/Allocator.h:447<br>
    #2 0x5aa115c in clang::TemplateIdAnnotation::<wbr>Create(clang::CXXScopeSpec, clang::SourceLocation, clang::SourceLocation, clang::IdentifierInfo*, clang::OverloadedOperatorKind, clang::OpaquePtr<clang::<wbr>TemplateName>, clang::TemplateNameKind, clang::SourceLocation, clang::SourceLocation, llvm::ArrayRef<clang::<wbr>ParsedTemplateArgument>, llvm::SmallVectorImpl<clang::<wbr>TemplateIdAnnotation*>&) /tmp/llvm/build/../tools/<wbr>clang/include/clang/Sema/<wbr>ParsedTemplate.h:202<br>
    #3 0x5b102e9 in clang::Parser::<wbr>AnnotateTemplateIdToken(clang:<wbr>:OpaquePtr<clang::<wbr>TemplateName>, clang::TemplateNameKind, clang::CXXScopeSpec&, clang::SourceLocation, clang::UnqualifiedId&, bool) /tmp/llvm/tools/clang/lib/<wbr>Parse/ParseTemplate.cpp:1042<br>
    #4 0x5a8f564 in clang::Parser::<wbr>ParseOptionalCXXScopeSpecifier<wbr>(clang::CXXScopeSpec&, clang::OpaquePtr<clang::<wbr>QualType>, bool, bool*, bool, clang::IdentifierInfo**, bool) /tmp/llvm/tools/clang/lib/<wbr>Parse/ParseExprCXX.cpp:497<br>
    #5 0x59fc010 in clang::Parser::<wbr>TryAnnotateCXXScopeToken(bool) /tmp/llvm/tools/clang/lib/<wbr>Parse/Parser.cpp:1886<br>
    #6 0x5a23ae9 in clang::Parser::<wbr>ParseDeclarationSpecifiers(<wbr>clang::DeclSpec&, clang::Parser::<wbr>ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::<wbr>DeclSpecContext, clang::Parser::<wbr>LateParsedAttrList*) /tmp/llvm/tools/clang/lib/<wbr>Parse/ParseDecl.cpp:3212<br>
    #7 0x5a11ff0 in clang::Parser::<wbr>ParseSpecifierQualifierList(<wbr>clang::DeclSpec&, clang::AccessSpecifier, clang::Parser::<wbr>DeclSpecContext) /tmp/llvm/tools/clang/lib/<wbr>Parse/ParseDecl.cpp:2389<br>
    #8 0x5a11c31 in clang::Parser::ParseTypeName(<wbr>clang::SourceRange*, clang::DeclaratorContext, clang::AccessSpecifier, clang::Decl**, clang::ParsedAttributes*) /tmp/llvm/tools/clang/lib/<wbr>Parse/ParseDecl.cpp:58<br>
    #9 0x5a39bcd in clang::Parser::<wbr>ParseFunctionDeclarator(clang:<wbr>:Declarator&, clang::ParsedAttributes&, clang::<wbr>BalancedDelimiterTracker&, bool, bool) /tmp/llvm/tools/clang/lib/<wbr>Parse/ParseDecl.cpp:6152<br>
    #10 0x5a3692c in clang::Parser::<wbr>ParseDirectDeclarator(clang::<wbr>Declarator&) /tmp/llvm/tools/clang/lib/<wbr>Parse/ParseDecl.cpp:5789<br>
    #11 0x5a34e6e in clang::Parser::<wbr>ParseDeclaratorInternal(clang:<wbr>:Declarator&, void (clang::Parser::*)(clang::<wbr>Declarator&)) /tmp/llvm/tools/clang/lib/<wbr>Parse/ParseDecl.cpp:5340<br>
    #12 0x5b0b10e in clang::Parser::<wbr>ParseSingleDeclarationAfterTem<wbr>plate(clang::<wbr>DeclaratorContext, clang::Parser::<wbr>ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) /tmp/llvm/tools/clang/lib/<wbr>Parse/ParseTemplate.cpp:238<br>
    #13 0x5b09d9b in clang::Parser::<wbr>ParseExplicitInstantiation(<wbr>clang::DeclaratorContext, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation&, clang::AccessSpecifier) /tmp/llvm/tools/clang/lib/<wbr>Parse/ParseTemplate.cpp:1318<br>
    #14 0x5b09b40 in clang::Parser::<wbr>ParseDeclarationStartingWithTe<wbr>mplate(clang::<wbr>DeclaratorContext, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) /tmp/llvm/tools/clang/lib/<wbr>Parse/ParseTemplate.cpp:34<br>
    #15 0x5a22609 in clang::Parser::<wbr>ParseDeclaration(clang::<wbr>DeclaratorContext, clang::SourceLocation&, clang::Parser::<wbr>ParsedAttributesWithRange&) /tmp/llvm/tools/clang/lib/<wbr>Parse/ParseDecl.cpp:1686<br>
    #16 0x59f4d97 in clang::Parser::<wbr>ParseExternalDeclaration(<wbr>clang::Parser::<wbr>ParsedAttributesWithRange&, clang::ParsingDeclSpec*) /tmp/llvm/tools/clang/lib/<wbr>Parse/Parser.cpp:786<br>
    #17 0x59f45d1 in clang::Parser::<wbr>ParseTopLevelDecl(clang::<wbr>OpaquePtr<clang::DeclGroupRef><wbr>&) /tmp/llvm/tools/clang/lib/<wbr>Parse/Parser.cpp:609<br>
    #18 0x59ee6bb in clang::ParseAST(clang::Sema&, bool, bool) /tmp/llvm/tools/clang/lib/<wbr>Parse/ParseAST.cpp:152<br>
    #19 0x3c95c64 in clang::FrontendAction::<wbr>Execute() /tmp/llvm/tools/clang/lib/<wbr>Frontend/FrontendAction.cpp:<wbr>904<br>
    #20 0x3c03f86 in clang::CompilerInstance::<wbr>ExecuteAction(clang::<wbr>FrontendAction&) /tmp/llvm/tools/clang/lib/<wbr>Frontend/CompilerInstance.cpp:<wbr>989<br>
    #21 0x3e0bf27 in clang::<wbr>ExecuteCompilerInvocation(<wbr>clang::CompilerInstance*) /tmp/llvm/tools/clang/lib/<wbr>FrontendTool/<wbr>ExecuteCompilerInvocation.cpp:<wbr>255<br>
    #22 0xf90faf in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /tmp/llvm/tools/clang/tools/<wbr>driver/cc1_main.cpp:221<br>
    #23 0xf818e9 in ExecuteCC1Tool(llvm::ArrayRef<<wbr>char const*>, llvm::StringRef) /tmp/llvm/tools/clang/tools/<wbr>driver/driver.cpp:310<br>
    #24 0xf81581 in main /tmp/llvm/tools/clang/tools/<wbr>driver/driver.cpp:390<br>
    #25 0x7f6051da4c04 in __libc_start_main ??:?<br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div>