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

Assertion failure when constraining non-template member of class template #21

Closed
davidstone opened this issue Sep 11, 2019 · 1 comment

Comments

@davidstone
Copy link

davidstone commented Sep 11, 2019

template<typename>
concept false_ = false;

template<typename T>
struct s {
	static void f(int) {}
	static void f(long) requires false_<T> {
	}
};


void f() {
	s<int>::f(1);
}

Gives an assertion failure:

clang-10: /home/david/llvm-concepts2/clang/lib/Sema/SemaTemplateInstantiate.cpp:1977: clang::QualType clang::Sema::SubstType(clang::QualType, const clang::MultiLevelTemplateArgumentList &, clang::SourceLocation, clang::DeclarationName): Assertion `!CodeSynthesisContexts.empty() && "Cannot perform an instantiation without some context on the " "instantiation stack"' failed.
Stack dump:
0. Program arguments: /home/david/llvm-concepts/build/bin/clang-10 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name file.cpp -mrelocation-model static -mthread-model posix -mframe-pointer=all -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -coverage-notes-file /dev/null.gcno -resource-dir /home/david/llvm-concepts/build/lib/clang/10.0.0 -internal-isystem /usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include/g++-v9 -internal-isystem /usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include/g++-v9/x86_64-pc-linux-gnu -internal-isystem /usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include/g++-v9/backward -internal-isystem /usr/local/include -internal-isystem /home/david/llvm-concepts/build/lib/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++2a -fdeprecated-macro -fdebug-compilation-dir /home/david/tm/build-bi-clang-debug/reduce -ferror-limit 19 -fmessage-length 0 -fno-implicit-modules -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -fconcepts-ts -o /dev/null -x c++ file.cpp

  1. file.cpp:13:13: current parser token ')'
  2. file.cpp:12:10: parsing function body 'f'
  3. file.cpp:12:10: in compound statement ('{}')
    #0 0x000000000304006d PrintStackTraceSignalHandler(void*) (.llvm.5230716231219214910) (/home/david/llvm-concepts/build/bin/clang-10+0x304006d)
    Should not define __cpp_concepts #1 0x000000000303d7f0 llvm::sys::RunSignalHandlers() (/home/david/llvm-concepts/build/bin/clang-10+0x303d7f0)
    Cannot yet mangle expression type RequiresExpr #2 0x0000000003040508 SignalHandler(int) (/home/david/llvm-concepts/build/bin/clang-10+0x3040508)
    'std::initializer_list<bool>' is not a literal type?? #3 0x00007fb535d9b660 __restore_rt (/lib64/libpthread.so.0+0x14660)
    Please add flag -fconcepts #4 0x00007fb5357acd21 raise (/lib64/libc.so.6+0x38d21)
    Friend declarations are not working? #5 0x00007fb535796535 abort (/lib64/libc.so.6+0x22535)
    Parsing: Retry as expression instead when reaching open-brace at block-scope #6 0x00007fb53579640f _nl_load_domain.cold (/lib64/libc.so.6+0x2240f)
    Wrong declaration lookup when compiled with module support (-fmodules) #7 0x00007fb5357a4712 (/lib64/libc.so.6+0x30712)
    Massive memory consumption to build relative simple classes #8 0x000000000500236e clang::Sema::SubstType(clang::QualType, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName) (/home/david/llvm-concepts/build/bin/clang-10+0x500236e)
    Redundant instantiation explanations #9 0x0000000005057ac4 addInstantiatedParametersToScope(clang::Sema&, clang::FunctionDecl*, clang::FunctionDecl const*, clang::LocalInstantiationScope&, clang::MultiLevelTemplateArgumentList const&) (/home/david/llvm-concepts/build/bin/clang-10+0x5057ac4)
    Some tests failing when built -DLLVM_ENABLE_ASSERTIONS=yes #10 0x0000000005057de9 clang::Sema::CheckFunctionConstraints(clang::FunctionDecl*, clang::ConstraintSatisfaction&) (/home/david/llvm-concepts/build/bin/clang-10+0x5057de9)
    crash #11 0x0000000004e794ba clang::Sema::AddMethodCandidate(clang::CXXMethodDecl*, clang::DeclAccessPair, clang::CXXRecordDecl*, clang::QualType, clang::Expr::Classification, llvm::ArrayRefclang::Expr*, clang::OverloadCandidateSet&, bool, bool, llvm::MutableArrayRefclang::ImplicitConversionSequence) (/home/david/llvm-concepts/build/bin/clang-10+0x4e794ba)
    Cannot default auto function parameters #12 0x0000000004e782b4 clang::Sema::AddOverloadCandidate(clang::FunctionDecl*, clang::DeclAccessPair, llvm::ArrayRefclang::Expr*, clang::OverloadCandidateSet&, bool, bool, bool, bool, clang::CallExpr::ADLCallKind, llvm::MutableArrayRefclang::ImplicitConversionSequence) (/home/david/llvm-concepts/build/bin/clang-10+0x4e782b4)
    How to build it? #13 0x0000000004e93570 AddOverloadedCallCandidate(clang::Sema&, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRefclang::Expr*, clang::OverloadCandidateSet&, bool, bool) (/home/david/llvm-concepts/build/bin/clang-10+0x4e93570)
    gcc standard library starts to include concepts #14 0x0000000004e9331e clang::Sema::AddOverloadedCallCandidates(clang::UnresolvedLookupExpr*, llvm::ArrayRefclang::Expr*, clang::OverloadCandidateSet&, bool) (/home/david/llvm-concepts/build/bin/clang-10+0x4e9331e)
    Constrained specialization of a template is rejected #15 0x0000000004e9373b clang::Sema::buildOverloadedCallSet(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, llvm::MutableArrayRefclang::Expr*, clang::SourceLocation, clang::OverloadCandidateSet*, clang::ActionResult<clang::Expr*, true>) (/home/david/llvm-concepts/build/bin/clang-10+0x4e9373b)
    Dependent class member access not correctly treated as lvalue in requires-expression #16 0x0000000004e93c1c clang::Sema::BuildOverloadedCallExpr(clang::Scope
    , clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRefclang::Expr*, clang::SourceLocation, clang::Expr*, bool, bool) (/home/david/llvm-concepts/build/bin/clang-10+0x4e93c1c)
    ICE parsing deduction guide for class template with constrained constructor #17 0x0000000004c12f58 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRefclang::Expr*, clang::SourceLocation, clang::Expr*, bool) (/home/david/llvm-concepts/build/bin/clang-10+0x4c12f58)
    Crash when explicitly qualifying namespace of concept when using void foo(thing auto) syntax #18 0x0000000004c30288 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRefclang::Expr*, clang::SourceLocation, clang::Expr*) (/home/david/llvm-concepts/build/bin/clang-10+0x4c30288)
    Cannot constrain constructor with terse syntax if concept has explicit parameters #19 0x000000000483b5a2 clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) (/home/david/llvm-concepts/build/bin/clang-10+0x483b5a2)
    Crashes with Type constraint should be initialized before we can access it #20 0x000000000483e8e2 clang::Parser::ParseCastExpression(clang::Parser::CastParseOption, bool, bool&, clang::Parser::TypeCastState, bool) (/home/david/llvm-concepts/build/bin/clang-10+0x483e8e2)
    Assertion failure when constraining non-template member of class template #21 0x00000000048389a5 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/home/david/llvm-concepts/build/bin/clang-10+0x48389a5)
    Concept definitions with unexpanded variadic template parameters evaluate to true #22 0x00000000047f58d5 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/home/david/llvm-concepts/build/bin/clang-10+0x47f58d5)
    Terse syntax does not work with noexcept clauses #23 0x00000000047f38d9 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) (/home/david/llvm-concepts/build/bin/clang-10+0x47f38d9)
    Assertion failure with member access of result of function declared with decltype(expr) return type #24 0x00000000047f323b clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/home/david/llvm-concepts/build/bin/clang-10+0x47f323b)
    Concepts ignored in arguments to lambdas #25 0x00000000047fcfae clang::Parser::ParseCompoundStatementBody(bool) (/home/david/llvm-concepts/build/bin/clang-10+0x47fcfae)
    fail to compile for libstdc++ #26 0x00000000047fe002 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/home/david/llvm-concepts/build/bin/clang-10+0x47fe002)
    Compiler ICE #27 0x00000000047db0af clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/home/david/llvm-concepts/build/bin/clang-10+0x47db0af)
    An auto parameter makes [[maybe_unused]] ignored on all parameters #28 0x0000000004825015 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/home/david/llvm-concepts/build/bin/clang-10+0x4825015)
    Caching ICE 1 #29 0x00000000047d9dc4 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/home/david/llvm-concepts/build/bin/clang-10+0x47d9dc4)
    Sema::getAssociatedConstraints incomplete result #30 0x00000000047d96af clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/home/david/llvm-concepts/build/bin/clang-10+0x47d96af)
    auto type deduction #31 0x00000000047d84d6 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/home/david/llvm-concepts/build/bin/clang-10+0x47d84d6)
    compiler crashes on calling a member of decltype(x) #32 0x00000000047d61dd clang::Parser::ParseTopLevelDecl(clang::OpaquePtrclang::DeclGroupRef&, bool) (/home/david/llvm-concepts/build/bin/clang-10+0x47d61dd)
    clangd crash in ParseOptionalCXXScopeSpecifier #33 0x00000000047d16f4 clang::ParseAST(clang::Sema&, bool, bool) (/home/david/llvm-concepts/build/bin/clang-10+0x47d16f4)
    Add missing setInvalidTypeConstraint() #34 0x000000000398080f clang::FrontendAction::Execute() (/home/david/llvm-concepts/build/bin/clang-10+0x398080f)
    Constraint not considered a constant expression in inherited constructor #35 0x00000000038df6a8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/david/llvm-concepts/build/bin/clang-10+0x38df6a8)
    Definition with the same mangled name #36 0x0000000003a2b327 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/david/llvm-concepts/build/bin/clang-10+0x3a2b327)
    Fix crash in cxx2a-constrained-template-param test. #37 0x0000000001fc93ee cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/david/llvm-concepts/build/bin/clang-10+0x1fc93ee)
    Unify invented template parameters #38 0x0000000001fc7168 main (/home/david/llvm-concepts/build/bin/clang-10+0x1fc7168)
    lambda call in default template argument generates mangling error #39 0x00007fb535797f1b __libc_start_main (/lib64/libc.so.6+0x23f1b)
    P0848R3 is not supported #40 0x0000000001fc402a _start (/home/david/llvm-concepts/build/bin/clang-10+0x1fc402a)
    clang-10: error: unable to execute command: Aborted (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.git 55730ed)
    Target: x86_64-unknown-linux-gnu
    Thread model: posix
    InstalledDir: /home/david/llvm-concepts/build/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/file-4a94bc.cpp
clang-10: note: diagnostic msg: /tmp/file-4a94bc.sh
clang-10: note: diagnostic msg:


@davidstone
Copy link
Author

Resolved in latest commit

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

1 participant