Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE parsing deduction guide for class template with constrained constructor #17

Open
CaseyCarter opened this issue Sep 2, 2019 · 1 comment

Comments

@CaseyCarter
Copy link

This well-formed TU:

template <class> concept C = true;

template <class T> struct S {
    template <C U> S(U) {}
};

template <class T> S(T&) -> S<T>;

ICEs the compiler with diagnostics (from my local debug build):

1.      /home/casey/casey/Desktop/repro.cpp:7:33: current parser token ';'
 #0 0x00007f81e103c5f3 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/casey/repos/clang-concepts/llvm/lib/Support/Unix/Signals.inc:533:22
 #1 0x00007f81e103c686 PrintStackTraceSignalHandler(void*) /home/casey/repos/clang-concepts/llvm/lib/Support/Unix/Signals.inc:594:1
 #2 0x00007f81e103a574 llvm::sys::RunSignalHandlers() /home/casey/repos/clang-concepts/llvm/lib/Support/Signals.cpp:68:20
 #3 0x00007f81e103bfad SignalHandler(int) /home/casey/repos/clang-concepts/llvm/lib/Support/Unix/Signals.inc:385:1
 #4 0x00007f81dd1f2890 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #5 0x00007f81e43d1cf1 (anonymous namespace)::ConvertConstructorToDeductionGuideTransform::transformTemplateParameter(clang::NamedDecl*, clang::MultiLevelTemplateArgumentList&) /home/casey/repos/clang-concepts/clang/lib/Sema/SemaTemplate.cpp:2028:42
 #6 0x00007f81e43d13f9 (anonymous namespace)::ConvertConstructorToDeductionGuideTransform::transformConstructor(clang::FunctionTemplateDecl*, clang::CXXConstructorDecl*) /home/casey/repos/clang-concepts/clang/lib/Sema/SemaTemplate.cpp:1938:69
 #7 0x00007f81e43d2e57 clang::Sema::DeclareImplicitDeductionGuides(clang::TemplateDecl*, clang::SourceLocation) /home/casey/repos/clang-concepts/clang/lib/Sema/SemaTemplate.cpp:2262:14
 #8 0x00007f81e41e1c07 DeclareImplicitMemberFunctionsWithName(clang::Sema&, clang::DeclarationName, clang::SourceLocation, clang::DeclContext const*) /home/casey/repos/clang-concepts/clang/lib/Sema/SemaLookup.cpp:911:5
 #9 0x00007f81e41e1cb3 LookupDirect(clang::Sema&, clang::LookupResult&, clang::DeclContext const*) /home/casey/repos/clang-concepts/clang/lib/Sema/SemaLookup.cpp:929:63
#10 0x00007f81e41e2339 CppNamespaceLookup(clang::Sema&, clang::LookupResult&, clang::ASTContext&, clang::DeclContext*, (anonymous namespace)::UnqualUsingDirectiveSet&) /home/casey/repos/clang-concepts/clang/lib/Sema/SemaLookup.cpp:1028:28
#11 0x00007f81e41e3372 clang::Sema::CppLookupName(clang::LookupResult&, clang::Scope*) /home/casey/repos/clang-concepts/clang/lib/Sema/SemaLookup.cpp:1408:11
#12 0x00007f81e41e4ad0 clang::Sema::LookupName(clang::LookupResult&, clang::Scope*, bool) /home/casey/repos/clang-concepts/clang/lib/Sema/SemaLookup.cpp:1930:5
#13 0x00007f81e3c39e2c clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) /home/casey/repos/clang-concepts/clang/lib/Sema/SemaDecl.cpp:5494:15
#14 0x00007f81e43eb431 clang::Sema::ActOnTemplateDeclarator(clang::Scope*, llvm::MutableArrayRef<clang::TemplateParameterList*>, clang::Declarator&) /home/casey/repos/clang-concepts/clang/lib/Sema/SemaTemplate.cpp:8351:35
#15 0x00007f81e39acf5b clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) /home/casey/repos/clang-concepts/clang/lib/Parse/ParseDecl.cpp:2269:14
#16 0x00007f81e39acac7 clang::Parser::ParseDeclarationAfterDeclarator(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&) /home/casey/repos/clang-concepts/clang/lib/Parse/ParseDecl.cpp:2217:70
#17 0x00007f81e3a5d827 clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) /home/casey/repos/clang-concepts/clang/lib/Parse/ParseTemplate.cpp:339:51
#18 0x00007f81e3a5ca43 clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) /home/casey/repos/clang-concepts/clang/lib/Parse/ParseTemplate.cpp:162:45
#19 0x00007f81e3a5c4b5 clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) /home/casey/repos/clang-concepts/clang/lib/Parse/ParseTemplate.cpp:36:50
#20 0x00007f81e39ab1c6 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) /home/casey/repos/clang-concepts/clang/lib/Parse/ParseDecl.cpp:1740:54
#21 0x00007f81e398d4ad clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (.localalias) /home/casey/repos/clang-concepts/clang/lib/Parse/Parser.cpp:865:77
#22 0x00007f81e398ca53 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool) /home/casey/repos/clang-concepts/clang/lib/Parse/Parser.cpp:683:42
#23 0x00007f81e39888d6 clang::ParseAST(clang::Sema&, bool, bool) /home/casey/repos/clang-concepts/clang/lib/Parse/ParseAST.cpp:158:37
#24 0x00007f81e1a8cecd clang::ASTFrontendAction::ExecuteAction() /home/casey/repos/clang-concepts/clang/lib/Frontend/FrontendAction.cpp:1041:11
#25 0x00007f81e2303ba1 clang::CodeGenAction::ExecuteAction() /home/casey/repos/clang-concepts/clang/lib/CodeGen/CodeGenAction.cpp:1060:1
#26 0x00007f81e1a8c830 clang::FrontendAction::Execute() /home/casey/repos/clang-concepts/clang/lib/Frontend/FrontendAction.cpp:938:38
#27 0x00007f81e1a28430 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/casey/repos/clang-concepts/clang/lib/Frontend/CompilerInstance.cpp:944:42
#28 0x00007f81e1bee37b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/casey/repos/clang-concepts/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:291:38      #29 0x00007f81dfa798bf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/casey/repos/clang-concepts/clang/tools/driver/cc1_main.cpp:249:40
#30 0x00007f81dfa6ef0d ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef) /home/casey/repos/clang-concepts/clang/tools/driver/driver.cpp:309:64
#31 0x00007f81dfa6f5eb main /home/casey/repos/clang-concepts/clang/tools/driver/driver.cpp:381:26
#32 0x00007f81dbe01b97 __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#33 0x00007f81dfa6d6fa _start (/home/casey/llvm/bin/clang-10+0x226d6fa)
clang-10: error: unable to execute command: Segmentation fault (core dumped)                                                                                                        clang-10: error: clang frontend command failed due to signal (use -v to see invocation)                                                                                             clang version 10.0.0 ([email protected]:saarraz/clang-concepts-monorepo 2b7ef558dc44fa5fe8ef29d5f20eca7b40174129)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/casey/llvm/bin
clang-10: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.               clang-10: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-10: note: diagnostic msg: /tmp/repro-0c2fd0.cpp                                                                                                                               clang-10: note: diagnostic msg: /tmp/repro-0c2fd0.sh                                                                                                                                clang-10: note: diagnostic msg:                                                                                                                                                     
********************
@davidstone
Copy link

This happens only with one of the terse forms. Using a requires clause prevents this.

saarraz pushed a commit that referenced this issue Jan 23, 2020
This reverts commit e57a9ab.

Parser/cxx2a-placeholder-type-constraint.cpp has MSan failures.

Present at 7b81c3f:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-msan/builds/17133/steps/check-clang%20msan/logs/stdio
not present at eaa594f:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-msan/builds/17132/steps/check-clang%20msan/logs/stdio

Stack trace:
```
==57032==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0xccfe016 in clang::AutoTypeLoc::getLocalSourceRange() const /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/include/clang/AST/TypeLoc.h:2036:19
    #1 0xcc56758 in CheckDeducedPlaceholderConstraints(clang::Sema&, clang::AutoType const&, clang::AutoTypeLoc, clang::QualType) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:4505:56
    #2 0xcc550ce in clang::Sema::DeduceAutoType(clang::TypeLoc, clang::Expr*&, clang::QualType&, llvm::Optional<unsigned int>, bool) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:4707:11
    #3 0xcc52407 in clang::Sema::DeduceAutoType(clang::TypeSourceInfo*, clang::Expr*&, clang::QualType&, llvm::Optional<unsigned int>, bool) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:4457:10
    #4 0xba38332 in clang::Sema::deduceVarTypeFromInitializer(clang::VarDecl*, clang::DeclarationName, clang::QualType, clang::TypeSourceInfo*, clang::SourceRange, bool, clang::Expr*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11351:7
    #5 0xba3a8a9 in clang::Sema::DeduceVariableDeclarationType(clang::VarDecl*, bool, clang::Expr*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11385:26
    #6 0xba3c520 in clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11725:9
    #7 0xb39c498 in clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:2399:17
    #8 0xb394d80 in clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:2128:21
    #9 0xb383bbf in clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:1848:10
    #10 0xb383129 in clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&, clang::SourceLocation*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/include/llvm/ADT/PointerUnion.h
    #11 0xb53a388 in clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseStmt.cpp:221:13
    #12 0xb539309 in clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseStmt.cpp:106:20
    #13 0xb55610e in clang::Parser::ParseCompoundStatementBody(bool) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseStmt.cpp:1079:11
    #14 0xb559529 in clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseStmt.cpp:2204:21
    #15 0xb33c13e in clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/Parser.cpp:1339:10
    #16 0xb394703 in clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:2068:11
    #17 0xb338e52 in clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/Parser.cpp:1099:10
    #18 0xb337674 in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/Parser.cpp:1115:12
    #19 0xb334a96 in clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/Parser.cpp:935:12
    #20 0xb32f12a in clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/Parser.cpp:686:12
    #21 0xb31e193 in clang::ParseAST(clang::Sema&, bool, bool) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseAST.cpp:158:20
    #22 0x80263f0 in clang::FrontendAction::Execute() /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Frontend/FrontendAction.cpp:936:8
    #23 0x7f2a257 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:965:33
    #24 0x8288bef in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:290:25
    #25 0xad44c2 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/tools/driver/cc1_main.cpp:239:15
    #26 0xacd76a in ExecuteCC1Tool(llvm::ArrayRef<char const*>) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/tools/driver/driver.cpp:325:12
    #27 0xacc9fd in main /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/tools/driver/driver.cpp:398:12
    #28 0x7f7d82cdb2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #29 0xa4dde9 in _start (/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang-11+0xa4dde9)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants