[llvm-bugs] [Bug 40636] New: EvaluateKnownConstInt crash when `if constexpr` condition contains reference to dependent type inside statement expression

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Feb 6 18:28:39 PST 2019


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

            Bug ID: 40636
           Summary: EvaluateKnownConstInt crash when `if constexpr`
                    condition contains reference to dependent type inside
                    statement expression
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: comexk at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

template <typename T>
void foo() {
    if constexpr(({ T::bar; })) {}
}


@ ~/llvmrootdbg/bin/clang++ -c foo.cpp -std=c++17
Assertion failed: (Result && "Could not evaluate expression"), function
EvaluateKnownConstInt, file
/Users/comex/src/llvm/clang/lib/AST/ExprConstant.cpp, line 11156.
Stack dump:
0.      Program arguments: /Users/comex/llvmrootdbg/bin/clang-8 -cc1 -triple
x86_64-apple-macosx10.15.0 -Wdeprecated-objc-isa-usage
-Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free
-main-file-name foo.cpp -mrelocation-model pic -pic-level 2 -mthread-model
posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu penryn
-dwarf-column-info -debugger-tuning=lldb -ggnu-pubnames -target-linker-version
500.1 -coverage-notes-file /Users/comex/foo.gcno -resource-dir
/Users/comex/llvmrootdbg/lib/clang/9.0.0 -stdlib=libc++ -internal-isystem
/Users/comex/llvmrootdbg/bin/../include/c++/v1 -std=c++17 -fdeprecated-macro
-fdebug-compilation-dir /Users/comex -ferror-limit 19 -fmessage-length 168
-stack-protector 1 -fblocks -fencode-extended-block-signature
-fregister-global-dtors-with-atexit -fobjc-runtime=macosx-10.15.0
-fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option
-fcolor-diagnostics -o foo.o -x c++ foo.cpp 
1.      foo.cpp:3:31: current parser token ')'
2.      foo.cpp:2:12: parsing function body 'foo'
3.      foo.cpp:2:12: in compound statement ('{}')
0  libLLVMSupport.dylib       0x00000001167edb9c
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
1  libLLVMSupport.dylib       0x00000001167ee169
PrintStackTraceSignalHandler(void*) + 25
2  libLLVMSupport.dylib       0x00000001167eb21e llvm::sys::RunSignalHandlers()
+ 990
3  libLLVMSupport.dylib       0x00000001167ef4a9 SignalHandler(int) + 505
4  libsystem_platform.dylib   0x00007fff5daac8bd _sigtramp + 29
5  libclangAST.dylib          0x000000011d9e3b78
getStmtInfoTableEntry(clang::Stmt::StmtClass)::Initialized + 215704
6  libsystem_c.dylib          0x00007fff5d96f88e abort + 127
7  libsystem_c.dylib          0x00007fff5d9383d1 basename_r + 0
8  libclangAST.dylib          0x000000011d6a90e3
clang::Expr::EvaluateKnownConstInt(clang::ASTContext const&,
llvm::SmallVectorImpl<std::__1::pair<clang::SourceLocation,
clang::PartialDiagnostic> >*) const + 243
9  libclangSema.dylib         0x00000001208c593b
clang::Sema::ConditionResult::ConditionResult(clang::Sema&, clang::Decl*,
clang::Sema::FullExprArg, bool) + 219
10 libclangSema.dylib         0x00000001208afa8e
clang::Sema::ConditionResult::ConditionResult(clang::Sema&, clang::Decl*,
clang::Sema::FullExprArg, bool) + 62
11 libclangSema.dylib         0x00000001208af98b
clang::Sema::ActOnCondition(clang::Scope*, clang::SourceLocation, clang::Expr*,
clang::Sema::ConditionKind) + 507
12 libclangParse.dylib        0x000000011fefdb54
clang::Parser::ParseCXXCondition(clang::ActionResult<clang::Stmt*, true>*,
clang::SourceLocation, clang::Sema::ConditionKind,
clang::Parser::ForRangeInfo*) + 1412
13 libclangParse.dylib        0x000000011ff635a4
clang::Parser::ParseParenExprOrCondition(clang::ActionResult<clang::Stmt*,
true>*, clang::Sema::ConditionResult&, clang::SourceLocation,
clang::Sema::ConditionKind) + 164
14 libclangParse.dylib        0x000000011ff5da72
clang::Parser::ParseIfStatement(clang::SourceLocation*) + 706
15 libclangParse.dylib        0x000000011ff5ad5b
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&) + 2299
16 libclangParse.dylib        0x000000011ff5a2c0
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*) + 160
17 libclangParse.dylib        0x000000011ff62c42
clang::Parser::ParseCompoundStatementBody(bool) + 1298
18 libclangParse.dylib        0x000000011ff63deb
clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) + 363
19 libclangParse.dylib        0x000000011ff8deef
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) +
4159
20 libclangParse.dylib        0x000000011ff74b46
clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext,
clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) +
2998
21 libclangParse.dylib        0x000000011ff73cc2
clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) +
1474
22 libclangParse.dylib        0x000000011ff735f6
clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) + 246
23 libclangParse.dylib        0x000000011fe7cab2
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 258
24 libclangParse.dylib        0x000000011ff8acf1
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 2321
25 libclangParse.dylib        0x000000011ff89fb6
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 1126
26 libclangParse.dylib        0x000000011ff89ade
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) +
46
27 libclangParse.dylib        0x000000011fe5ed0e clang::ParseAST(clang::Sema&,
bool, bool) + 798
28 libclangFrontend.dylib     0x0000000119d2ade9
clang::ASTFrontendAction::ExecuteAction() + 489
29 libclangCodeGen.dylib      0x00000001187dfa52
clang::CodeGenAction::ExecuteAction() + 4466
30 libclangFrontend.dylib     0x0000000119d29b80
clang::FrontendAction::Execute() + 112
31 libclangFrontend.dylib     0x0000000119c55c88
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 3192
32 libclangFrontendTool.dylib 0x0000000117f0b112
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 4722
33 clang-8                    0x000000010afec19b cc1_main(llvm::ArrayRef<char
const*>, char const*, void*) + 4635
34 clang-8                    0x000000010afdda57
ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef) + 167
35 clang-8                    0x000000010afdc0f2 main + 1682
36 libdyld.dylib              0x00007fff5d8c54dd start + 1

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190207/ad493ef1/attachment.html>


More information about the llvm-bugs mailing list