-
Notifications
You must be signed in to change notification settings - Fork 13.4k
clang crashes in clang/lib/AST/ExprConstant.cpp:14737 Assertion `!isValueDependent() && "Expression evaluator can't be called on a dependent expression."' failed #49570
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
Comments
A possible duplicate. $ clang-trunk -v
clang version 13.0.0 (https://github.com/llvm/llvm-project.git ef906573a127cffef7cae75d5155c15a8a2a3a5e)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/cnsun/usr/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$ cat mutant.c main() {
unsigned a unsigned b;
__atomic_fetch_xor(&a, b, sizeof x);
} $ clang-trunk mutant.c
mutant.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main() {
^
mutant.c:2:13: error: expected ';' at end of declaration
unsigned a unsigned b;
^
;
clang-13: /tmp/tmp.B1HwadcXIH-clang-builder/llvm-project/clang/lib/AST/ExprConstant.cpp:15525: llvm::Optional<llvm::APSInt> clang::Expr::getIntegerConstantExpr(const clang::ASTContext&, clang::SourceLocation*, bool) 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:
0. Program arguments: /scratch/software/clang-trunk/bin/clang-13 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -main-file-name mutant.c -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/scratch/cnsun/workspace/perses-fuzzer/default_c_finding_folder/crash_20210625_140252_1028/delta/perses_result -resource-dir /scratch/software/clang-trunk/lib/clang/13.0.0 -c-isystem . -c-isystem /usr/local/include/cmsith -internal-isystem /scratch/software/clang-trunk/lib/clang/13.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/scratch/cnsun/workspace/perses-fuzzer/default_c_finding_folder/crash_20210625_140252_1028/delta/perses_result -ferror-limit 19 -fgnuc-version=4.2.1 -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/mutant-76d37d.o -x c mutant.c
1. mutant.c:3:37: current parser token ')'
2. mutant.c:1:8: parsing function body 'main'
3. mutant.c:1:8: in compound statement ('{}')
#​0 0x000055860b5931f4 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#​1 0x000055860b5909ae SignalHandler(int) Signals.cpp:0:0
#​2 0x00007f0e065d93c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#​3 0x00007f0e0607818b raise /build/glibc-ZN95T4/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#​4 0x00007f0e06057859 abort /build/glibc-ZN95T4/glibc-2.31/stdlib/abort.c:81:7
#​5 0x00007f0e06057729 get_sysdep_segment_value /build/glibc-ZN95T4/glibc-2.31/intl/loadmsgcat.c:509:8
#​6 0x00007f0e06057729 _nl_load_domain /build/glibc-ZN95T4/glibc-2.31/intl/loadmsgcat.c:970:34
#​7 0x00007f0e06068f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
#​8 0x000055860e698391 clang::Expr::getIntegerConstantExpr(clang::ASTContext const&, clang::SourceLocation*, bool) const (/scratch/software/clang-trunk/bin/clang-13+0x6a5e391)
#​9 0x000055860d9483d3 clang::Sema::BuildAtomicExpr(clang::SourceRange, clang::SourceRange, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::AtomicExpr::AtomicOp, clang::Sema::AtomicArgumentOrder) (/scratch/software/clang-trunk/bin/clang-13+0x5d0e3d3)
#​10 0x000055860d9487c0 clang::Sema::SemaAtomicOpsOverloaded(clang::ActionResult<clang::Expr*, true>, clang::AtomicExpr::AtomicOp) (/scratch/software/clang-trunk/bin/clang-13+0x5d0e7c0)
#​11 0x000055860d97c45b clang::Sema::CheckBuiltinFunctionCall(clang::FunctionDecl*, unsigned int, clang::CallExpr*) (/scratch/software/clang-trunk/bin/clang-13+0x5d4245b)
#​12 0x000055860dc549c7 clang::Sema::BuildResolvedCallExpr(clang::Expr*, clang::NamedDecl*, clang::SourceLocation, llvm::ArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, clang::CallExpr::ADLCallKind) (/scratch/software/clang-trunk/bin/clang-13+0x601a9c7)
#​13 0x000055860dc5597b clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/scratch/software/clang-trunk/bin/clang-13+0x601b97b)
#​14 0x000055860dc56d3d clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) (/scratch/software/clang-trunk/bin/clang-13+0x601cd3d)
#​15 0x000055860d80a7cb clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) (/scratch/software/clang-trunk/bin/clang-13+0x5bd07cb)
#​16 0x000055860d8038d2 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/scratch/software/clang-trunk/bin/clang-13+0x5bc98d2)
#​17 0x000055860d8063cb clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/scratch/software/clang-trunk/bin/clang-13+0x5bcc3cb)
#​18 0x000055860d80646d clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/scratch/software/clang-trunk/bin/clang-13+0x5bcc46d)
#​19 0x000055860d8099cd clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/scratch/software/clang-trunk/bin/clang-13+0x5bcf9cd)
#​20 0x000055860d87160e clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/scratch/software/clang-trunk/bin/clang-13+0x5c3760e)
#​21 0x000055860d868ba2 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributesWithRange&) (/scratch/software/clang-trunk/bin/clang-13+0x5c2eba2)
#​22 0x000055860d86958a clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/scratch/software/clang-trunk/bin/clang-13+0x5c2f58a)
#​23 0x000055860d86a509 clang::Parser::ParseCompoundStatementBody(bool) (/scratch/software/clang-trunk/bin/clang-13+0x5c30509)
#​24 0x000055860d86cb1a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/scratch/software/clang-trunk/bin/clang-13+0x5c32b1a)
#​25 0x000055860d7b2db2 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/scratch/software/clang-trunk/bin/clang-13+0x5b78db2)
#​26 0x000055860d7df710 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/scratch/software/clang-trunk/bin/clang-13+0x5ba5710)
#​27 0x000055860d7ad5b6 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/scratch/software/clang-trunk/bin/clang-13+0x5b735b6)
#​28 0x000055860d7adba1 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#​29 0x000055860d7b43a7 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/scratch/software/clang-trunk/bin/clang-13+0x5b7a3a7)
#​30 0x000055860d7b593e clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool) (/scratch/software/clang-trunk/bin/clang-13+0x5b7b93e)
#​31 0x000055860d7b5ce9 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) (/scratch/software/clang-trunk/bin/clang-13+0x5b7bce9)
#​32 0x000055860d7a815a clang::ParseAST(clang::Sema&, bool, bool) (/scratch/software/clang-trunk/bin/clang-13+0x5b6e15a)
#​33 0x000055860c6ef458 clang::CodeGenAction::ExecuteAction() (/scratch/software/clang-trunk/bin/clang-13+0x4ab5458)
#​34 0x000055860bf9e9e9 clang::FrontendAction::Execute() (/scratch/software/clang-trunk/bin/clang-13+0x43649e9)
#​35 0x000055860bf31c36 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/scratch/software/clang-trunk/bin/clang-13+0x42f7c36)
#​36 0x000055860c07c870 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/scratch/software/clang-trunk/bin/clang-13+0x4442870)
#​37 0x0000558608e9c696 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/scratch/software/clang-trunk/bin/clang-13+0x1262696)
#​38 0x0000558608e989d8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#​39 0x0000558608dc60e6 main (/scratch/software/clang-trunk/bin/clang-13+0x118c0e6)
#​40 0x00007f0e060590b3 __libc_start_main /build/glibc-ZN95T4/glibc-2.31/csu/../csu/libc-start.c:342:3
#​41 0x0000558608e9854e _start (/scratch/software/clang-trunk/bin/clang-13+0x125e54e)
clang-13: error: unable to execute command: Aborted (core dumped)
clang-13: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 13.0.0 (https://github.com/llvm/llvm-project.git ef906573a127cffef7cae75d5155c15a8a2a3a5e)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/cnsun/usr/bin
clang-13: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-13: note: diagnostic msg: /tmp/mutant-2d6fad.c
clang-13: note: diagnostic msg: /tmp/mutant-2d6fad.sh
clang-13: note: diagnostic msg:
******************** |
Still crashes on current |
I am running into this crash in Clang 17 when working with std::byte.
|
Here's a minimal repro that triggers this assert without __m128i involved. Just running clang with -std=c++20: #include <concepts>
#include <stdint.h>
#include <cstddef>
template <class T>
concept EnumClass =
!requires(T t) {
{
[](std::underlying_type_t<T>) {}(t)
};
};
template <class To, class From>
struct TransmogrifyImpl;
template <class T, EnumClass F>
struct TransmogrifyImpl<T, F>
{
constexpr static T mog_from(const F &from) noexcept
{
return static_cast<std::underlying_type_t<F>>(from);
}
};
int main()
{
return TransmogrifyImpl<uint32_t, std::byte>::mog_from(std::byte{0xff});
}
|
I think it's caused in this case by putting a concept in a partial specialization. |
Assertion: clang: /root/llvm-project/clang/lib/AST/ExprConstant.cpp:15370:
bool clang::Expr::EvaluateAsInt(clang::Expr::EvalResult&, const clang::ASTContext&, clang::Expr::SideEffectsKind, bool) const:
Assertion `!isValueDependent() && "Expression evaluator can't be called on a dependent expression."' failed. |
…83997) The dependency of a lambda inside of a `RequiresExprBodyDecl` was previously affected by its parent, e.g., `ClassTemplateSpecializationDecl`. This made the lambda always dependent regardless of the template arguments we had, which caused some crashes on the constraint evaluation later. This fixes #56556, fixes #82849 and a case demonstrated by #49570 (comment).
The reduced version no longer crashes on trunk but the original does. |
Extended Description
Hi all.
The small program emits one error then crashes. This crash only occurs in the current trunk of clang, so I guess clang should be more friendly and exit normally in this case?
$cat small.c
Thanks,
Haoxin
The text was updated successfully, but these errors were encountered: