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

consteval crash in codegen #53795

Closed
davidbolvansky opened this issue Feb 12, 2022 · 5 comments
Closed

consteval crash in codegen #53795

davidbolvansky opened this issue Feb 12, 2022 · 5 comments
Labels
c++20 clang:codegen IR generation bugs: mangling, exceptions, etc. confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@davidbolvansky
Copy link
Collaborator

davidbolvansky commented Feb 12, 2022

struct array {
	char buffer[1];
};

struct fixed_string: array {
	constexpr fixed_string(): array{} { }
};

consteval auto get_fixed_string() noexcept {
	return fixed_string{};
}

void foo() {
    get_fixed_string();
}

clang -std=c++20 -O0 -emit-llvm
https://compiler-explorer.com/z/6W156T5db

void llvm::StoreInst::AssertOK(): Assertion `cast<PointerType>(getOperand(1)->getType()) -isOpaqueOrPointeeTypeMatches(getOperand(0)->getType()) && "Ptr must be a pointer to Val type!"' 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: /usr/local/bin/clang-13 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -main-file-name constevalcrash.cpp -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/home/xbolva00/AirStatus -resource-dir /usr/local/lib/clang/15.0.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward -internal-isystem /usr/local/lib/clang/15.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/8/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++20 -fdeprecated-macro -fdebug-compilation-dir=/home/xbolva00/AirStatus -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/constevalcrash-da08db.o -x c++ constevalcrash.cpp
1.      <eof> parser at end of file
2.      constevalcrash.cpp:13:6: LLVM IR generation of declaration 'foo'
3.      constevalcrash.cpp:13:6: Generating code for declaration 'foo'
 #0 0x000055ead86562af PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x000055ead86538ee SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f6a38c928a0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
 #3 0x00007f6a37943f47 raise /build/glibc-2ORdQG/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #4 0x00007f6a379458b1 abort /build/glibc-2ORdQG/glibc-2.27/stdlib/abort.c:81:0
 #5 0x00007f6a3793542a __assert_fail_base /build/glibc-2ORdQG/glibc-2.27/assert/assert.c:89:0
 #6 0x00007f6a379354a2 (/lib/x86_64-linux-gnu/libc.so.6+0x304a2)
 #7 0x000055ead7cf69ec llvm::StoreInst::AssertOK() (/usr/local/bin/clang-13+0x30589ec)
 #8 0x000055ead7cf6be3 llvm::StoreInst::StoreInst(llvm::Value*, llvm::Value*, bool, llvm::Align, llvm::Instruction*) (/usr/local/bin/clang-13+0x3058be3)
 #9 0x000055ead8c7c49a clang::CodeGen::CodeGenFunction::EmitAggregateStore(llvm::Value*, clang::CodeGen::Address, bool) (/usr/local/bin/clang-13+0x3fde49a)
#10 0x000055ead8d0d2df (anonymous namespace)::AggExprEmitter::VisitConstantExpr(clang::ConstantExpr*) CGExprAgg.cpp:0:0
#11 0x000055ead8d0955b clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::AggExprEmitter, void>::Visit(clang::Stmt*) CGExprAgg.cpp:0:0
#12 0x000055ead8d0aa3a (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) CGExprAgg.cpp:0:0
@davidbolvansky
Copy link
Collaborator Author

cc @zygoloid

@davidbolvansky davidbolvansky added the clang:codegen IR generation bugs: mangling, exceptions, etc. label Feb 12, 2022
@llvmbot
Copy link
Member

llvmbot commented Feb 12, 2022

@llvm/issue-subscribers-clang-codegen

@EugeneZelenko EugeneZelenko added c++20 crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Feb 12, 2022
@llvmbot
Copy link
Member

llvmbot commented Feb 12, 2022

@llvm/issue-subscribers-c-20

@AaronBallman AaronBallman added the confirmed Verified by a second party label Feb 13, 2022
@AaronBallman
Copy link
Collaborator

I think this may be related to or a duplicate of #51764.

@xgupta
Copy link
Contributor

xgupta commented Jun 27, 2022

No crash on trunk, fine to close.

@xgupta xgupta closed this as completed Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++20 clang:codegen IR generation bugs: mangling, exceptions, etc. confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

No branches or pull requests

5 participants