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

            Bug ID: 52422
           Summary: consteval constructor causes "Assertion
                    `cast<PointerType>(getOperand(1)->getType())
                    ->isOpaqueOrPointeeTypeMatches(getOperand(0)->getType(
                    )) && "Ptr must be a pointer to Val type!"' failed"
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

At least with clang-13.0.0~rc1-1.fc35.x86_64 and with recent Clang 14 trunk,

> $ cat test.cc
> struct S {
>     consteval S() {}
>     union {
>         int a;
>         struct { int b; } c = {0};
>     };
> };
> void f() { S(); }

> clang++ -std=c++20 -c test.cc
> test.cc:8:12: warning: expression result unused [-Wunused-value]
> void f() { S(); }
>            ^~~
> clang++: llvm/lib/IR/Instructions.cpp:1492: void llvm::StoreInst::AssertOK(): 
> Assertion `cast<PointerType>(getOperand(1)->getType()) 
> ->isOpaqueOrPointeeTypeMatches(getOperand(0)->getType()) && "Ptr must be a 
> pointer to Val type!"' failed.
[...]
>  #7 0x00007fe1bbcf07d3 abort (/lib64/libc.so.6+0x2c7d3)
>  #8 0x00007fe1bbcf06fb _nl_load_domain.cold (/lib64/libc.so.6+0x2c6fb)
>  #9 0x00007fe1bbcff3a6 (/lib64/libc.so.6+0x3b3a6)
> #10 0x00000000021bf9a2 llvm::Align::Align(unsigned long) 
> llvm/include/llvm/Support/Alignment.h:78:5
> #11 0x00000000021bf9a2 llvm::StoreInst::getAlign() const 
> llvm/include/llvm/IR/Instructions.h:354:12
> #12 0x00000000021bf9a2 llvm::StoreInst::getAlignment() const 
> llvm/include/llvm/IR/Instructions.h:351:42
> #13 0x00000000021bf9a2 llvm::StoreInst::AssertOK() 
> llvm/lib/IR/Instructions.cpp:1493:3
> #14 0x00000000021bfb8f llvm::StoreInst::StoreInst(llvm::Value*, llvm::Value*, 
> bool, llvm::Align, llvm::Instruction*) llvm/lib/IR/Instructions.cpp:1517:7
> #15 0x0000000000a28250 llvm::Twine::Twine(char const*) 
> llvm/include/llvm/ADT/Twine.h:170:14
> #16 0x0000000000a28250 llvm::IRBuilderBase::CreateAlignedStore(llvm::Value*, 
> llvm::Value*, llvm::MaybeAlign, bool) llvm/include/llvm/IR/IRBuilder.h:1757:12
> #17 0x0000000002e7fd93 
> clang::CodeGen::CodeGenFunction::EmitAggregateStore(llvm::Value*, 
> clang::CodeGen::Address, bool) clang/lib/CodeGen/CGCall.cpp:1316:61
> #18 0x0000000002ef5a44 (anonymous 
> namespace)::AggExprEmitter::VisitConstantExpr(clang::ConstantExpr*) 
> clang/lib/CodeGen/CGExprAgg.cpp:0:11
> #19 0x0000000002efac8c (anonymous 
> namespace)::AggExprEmitter::VisitCastExpr(clang::CastExpr*) 
> clang/lib/CodeGen/CGExprAgg.cpp:0:0
> #20 0x0000000002ef0737 (anonymous 
> namespace)::AggExprEmitter::Visit(clang::Expr*) 
> clang/lib/CodeGen/CGExprAgg.cpp:108:3
> #21 0x0000000002ef0737 
> clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, 
> clang::CodeGen::AggValueSlot) clang/lib/CodeGen/CGExprAgg.cpp:2000:49
> #22 0x0000000002ed0e80 clang::CodeGen::AggValueSlot::isIgnored() const 
> clang/lib/CodeGen/CGValue.h:620:17
> #23 0x0000000002ed0e80 clang::CodeGen::AggValueSlot::asRValue() const 
> clang/lib/CodeGen/CGValue.h:640:9
> #24 0x0000000002ed0e80 
> clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, 
> clang::CodeGen::AggValueSlot, bool) clang/lib/CodeGen/CGExpr.cpp:214:20
> #25 0x0000000002ed0d49 
> clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) 
> clang/lib/CodeGen/CGExpr.cpp:196:1
> #26 0x0000000002c593a5 llvm::IRBuilderBase::GetInsertBlock() const 
> llvm/include/llvm/IR/IRBuilder.h:178:47
> #27 0x0000000002c593a5 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt 
> const*, llvm::ArrayRef<clang::Attr const*>) 
> clang/lib/CodeGen/CGStmt.cpp:123:42
> #28 0x0000000002c6511c 
> clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
>  const&, bool, clang::CodeGen::AggValueSlot) 
> clang/lib/CodeGen/CGStmt.cpp:468:22
> #29 0x0000000002cbebae 
> clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) 
> clang/lib/CodeGen/CodeGenFunction.cpp:0:5
[...]

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to