Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Assertion "Expression evaluator can't be called on a dependent expression." when a consteval function called. #48811

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR49842
Status CONFIRMED
Importance P enhancement
Reported by Balazs Benics (balazs.benics@sigmatechnology.se)
Reported on 2021-04-05 08:12:22 -0700
Last modified on 2021-10-14 12:10:49 -0700
Version trunk
Hardware PC Windows NT
CC aaron@aaronballman.com, blitzrakete@gmail.com, erik.pilkington@gmail.com, hokein@google.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

Here is the code snippet which triggers the assertion at line 14816 of ExprConstant.cpp.

https://github.com/llvm/llvm-project/blob/3315bd0beb4cf23f838bd522a1f0e3fcc0a9fae2/clang/lib/AST/ExprConstant.cpp#L14816-L14817

consteval int id(int x) { return x; }

template <typename T>
struct foo {
  static constexpr auto dependent = id(alignof(T));
};

Here is the godbolt link demonstrating the crash: https://godbolt.org/z/PrPqaP8M9

The stack trace: clang++: /root/llvm-project/clang/lib/AST/ExprConstant.cpp:14817: bool clang::Expr::EvaluateAsConstantExpr(clang::Expr::EvalResult&, const clang::ASTContext&, clang::Expr::ConstantExprKind) const: Assertion `!isValueDependent() && "Expression evaluator can't be called on a dependent expression."' failed. PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump:

  1. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o ./output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O3 -Wall -Wextra -std=c++20
  2. :5:51: current parser token ';'
  3. :4:1: parsing struct/union/class body 'foo'

    0 0x000056090be5bedc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3595edc)

    1 0x000056090be59ba4 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3593ba4)

    2 0x000056090be59e25 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3593e25)

    3 0x000056090bdb4af8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0

    4 0x00007f086a5e33c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)

    5 0x00007f086a0b318b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4618b)

    6 0x00007f086a092859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x25859)

    7 0x00007f086a092729 (/lib/x86_64-linux-gnu/libc.so.6+0x25729)

    8 0x00007f086a0a3f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)

    9 0x000056090e83473d clang::Expr::EvaluateAsConstantExpr(clang::Expr::EvalResult&, clang::ASTContext const&, clang::Expr::ConstantExprKind) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5f6e73d)

    10 0x000056090df87198 clang::Sema::PopExpressionEvaluationContext() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x56c1198)

    11 0x000056090dc12e89 clang::Parser::ParseCXXMemberInitializer(clang::Decl*, bool, clang::SourceLocation&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x534ce89)

    12 0x000056090dc1f9a1 clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x53599a1)

    13 0x000056090dc1feca clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&, clang::ParsedAttributesWithRange&, clang::TypeSpecifierType, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5359eca)

    14 0x000056090dc20891 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributesWithRange&, unsigned int, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x535a891)

    15 0x000056090dc22fda clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributesWithRange&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x535cfda)

    16 0x000056090dc0543c clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x533f43c)

    17 0x000056090dc91ed5 clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x53cbed5)

    18 0x000056090dc9c8a3 clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x53d68a3)

    19 0x000056090dc9cc79 clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x53d6c79)

    20 0x000056090dc0aea6 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributesWithRange&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5344ea6)

    21 0x000056090dbe551d clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x531f51d)

    22 0x000056090dbe6139 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5320139)

    23 0x000056090dbdc679 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5316679)

    24 0x000056090cd946b8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44ce6b8)

    25 0x000056090c71c451 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e56451)

    26 0x000056090c6b7a72 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3df1a72)

    27 0x000056090c7e7b7a clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f21b7a)

    28 0x0000560909b0afbc cc1_main(llvm::ArrayRef<char const>, char const, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1244fbc)

    29 0x0000560909b062d9 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0

    30 0x000056090c575ce5 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) const::'lambda'()>(long) Job.cpp:0:0

    31 0x000056090bdb4bd3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x34eebd3)

    32 0x000056090c576684 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) const (.part.162) Job.cpp:0:0

    33 0x000056090c54e7da clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c887da)

    34 0x000056090c54f47f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c8947f)

    35 0x000056090c557e1a clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c91e1a)

    36 0x0000560909a1f1e0 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x11591e0)

    37 0x00007f086a0940b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3)

    38 0x0000560909b05e1a _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x123fe1a)

    clang-13: error: clang frontend command failed with exit code 134 (use -v to see invocation) Compiler returned: 134

Quuxplusone commented 3 years ago

Feel free to CC anyone who might be interesting in this crash.