[llvm-bugs] [Bug 50181] New: const clang::ArrayType *clang::Type::castAsArrayTypeUnsafe() const: Assertion `isa<ArrayType>(CanonicalType)' failed.

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 30 08:25:48 PDT 2021


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

            Bug ID: 50181
           Summary: const clang::ArrayType
                    *clang::Type::castAsArrayTypeUnsafe() const: Assertion
                    `isa<ArrayType>(CanonicalType)' failed.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rmansfield 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,
                    wchilders at lock3software.com

$ cat ice.ii
typedef struct {
  char *a;
} b;
struct c {
  b c;
} d{(char[]){""}};

$ bin/clang ice.ii
clang-13:
/home/ryan_mansfield/llvm/llvm-project/clang/include/clang/AST/Type.h:7232:
const clang::ArrayType *clang::Type::castAsArrayTypeUnsafe() const: Assertion
`isa<ArrayType>(CanonicalType)' 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:
/home/ryan_mansfield/llvm/llvm-project/build/bin/clang-13 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations
-disable-free -main-file-name ice.ii -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=/home/ryan_mansfield/llvm/llvm-project/build
-resource-dir /home/ryan_mansfield/llvm/llvm-project/build/lib/clang/13.0.0
-fdeprecated-macro
-fdebug-compilation-dir=/home/ryan_mansfield/llvm/llvm-project/build
-ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions
-fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o
/tmp/ice-04ea8a.o -x c++-cpp-output ice.ii
1.      <eof> parser at end of file
2.      ice.ii:4:8: LLVM IR generation of declaration 'c'
3.      ice.ii:6:3: Generating code for declaration 'd'
 #0 0x0000000001e40bd3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/home/ryan_mansfield/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:13
 #1 0x0000000001e3ecb0 llvm::sys::RunSignalHandlers()
/home/ryan_mansfield/llvm/llvm-project/llvm/lib/Support/Signals.cpp:77:18
 #2 0x0000000001e4109f SignalHandler(int)
/home/ryan_mansfield/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #3 0x00007ffff79ae980 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #4 0x00007ffff6505fb7 raise
/build/glibc-S7xCS9/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007ffff6507921 abort /build/glibc-S7xCS9/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007ffff64f748a __assert_fail_base
/build/glibc-S7xCS9/glibc-2.27/assert/assert.c:89:0
 #7 0x00007ffff64f7502 (/lib/x86_64-linux-gnu/libc.so.6+0x30502)
 #8 0x000000000235205a llvm::cast_retty<clang::ArrayType, clang::Type
const*>::ret_type llvm::cast<clang::ArrayType, clang::Type const>(clang::Type
const*)
/home/ryan_mansfield/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:269:3
 #9 0x000000000235205a clang::Type::castAsArrayTypeUnsafe() const
/home/ryan_mansfield/llvm/llvm-project/clang/include/clang/AST/Type.h:7234:10
#10 0x00000000043090ed clang::APValue::isArray() const
/home/ryan_mansfield/llvm/llvm-project/clang/include/clang/AST/APValue.h:400:38
#11 0x00000000043090ed clang::APValue::getArrayInitializedElts() const
/home/ryan_mansfield/llvm/llvm-project/clang/include/clang/AST/APValue.h:522:5
#12 0x00000000043090ed CheckEvaluationResult(CheckEvaluationResultKind,
(anonymous namespace)::EvalInfo&, clang::SourceLocation, clang::QualType,
clang::APValue const&, clang::Expr::ConstantExprKind, clang::SourceLocation,
llvm::SmallPtrSet<clang::MaterializeTemporaryExpr const*, 8u>&)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/AST/ExprConstant.cpp:2355:36
#13 0x0000000004309156 CheckEvaluationResult(CheckEvaluationResultKind,
(anonymous namespace)::EvalInfo&, clang::SourceLocation, clang::QualType,
clang::APValue const&, clang::Expr::ConstantExprKind, clang::SourceLocation,
llvm::SmallPtrSet<clang::MaterializeTemporaryExpr const*, 8u>&)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/AST/ExprConstant.cpp:2356:12
#14 0x00000000042daedd CheckConstantExpression((anonymous
namespace)::EvalInfo&, clang::SourceLocation, clang::QualType, clang::APValue
const&, clang::Expr::ConstantExprKind)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/AST/ExprConstant.cpp:2423:10
#15 0x00000000042dc34b EvaluateAsRValue((anonymous namespace)::EvalInfo&,
clang::Expr const*, clang::APValue&)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/AST/ExprConstant.cpp:14627:60
#16 0x00000000042d89e6 EvaluateAsRValue(clang::Expr const*,
clang::Expr::EvalResult&, clang::ASTContext const&, (anonymous
namespace)::EvalInfo&)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/AST/ExprConstant.cpp:14673:10
#17 0x00000000042d89e6 clang::Expr::EvaluateAsRValue(clang::Expr::EvalResult&,
clang::ASTContext const&, bool) const
/home/ryan_mansfield/llvm/llvm-project/clang/lib/AST/ExprConstant.cpp:14721:10
#18 0x00000000020c413d
clang::CodeGen::ConstantEmitter::tryEmitPrivate(clang::Expr const*,
clang::QualType)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:1727:15
#19 0x00000000020c76cb
clang::CodeGen::ConstantEmitter::tryEmitPrivateForMemory(clang::Expr const*,
clang::QualType)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:1674:11
#20 0x00000000020c76cb
clang::CodeGen::ConstantEmitter::tryEmitForInitializer(clang::Expr const*,
clang::LangAS, clang::QualType)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:1416:23
#21 0x00000000020c76cb (anonymous
namespace)::tryEmitGlobalCompoundLiteral(clang::CodeGen::CodeGenModule&,
clang::CodeGen::CodeGenFunction*, clang::CompoundLiteralExpr const*)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:907:31
#22 0x00000000020c9704 (anonymous
namespace)::ConstantLValueEmitter::VisitCompoundLiteralExpr(clang::CompoundLiteralExpr
const*)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:0:10
#23 0x00000000020c9704 clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous
namespace)::ConstantLValueEmitter, (anonymous
namespace)::ConstantLValue>::Visit(clang::Stmt const*)
/home/ryan_mansfield/llvm/llvm-project/build/tools/clang/include/clang/AST/StmtNodes.inc:979:1
#24 0x00000000020c4d89 (anonymous
namespace)::ConstantLValueEmitter::tryEmitBase(clang::APValue::LValueBase
const&)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:1927:10
#25 0x00000000020c4d89 (anonymous namespace)::ConstantLValueEmitter::tryEmit()
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:1838:27
#26 0x00000000020c4d89
clang::CodeGen::ConstantEmitter::tryEmitPrivate(clang::APValue const&,
clang::QualType)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:2042:58
#27 0x00000000020ca47b
clang::CodeGen::ConstantEmitter::tryEmitPrivateForMemory(clang::APValue const&,
clang::QualType)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:1681:11
#28 0x00000000020ca47b (anonymous
namespace)::ConstStructBuilder::Build(clang::APValue const&, clang::RecordDecl
const*, bool, clang::CXXRecordDecl const*, clang::CharUnits)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:829:15
#29 0x00000000020c4382 (anonymous
namespace)::ConstStructBuilder::BuildStruct(clang::CodeGen::ConstantEmitter&,
clang::APValue const&, clang::QualType)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:879:7
#30 0x00000000020c4382
clang::CodeGen::ConstantEmitter::tryEmitPrivate(clang::APValue const&,
clang::QualType)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:2119:12
#31 0x00000000020ca47b
clang::CodeGen::ConstantEmitter::tryEmitPrivateForMemory(clang::APValue const&,
clang::QualType)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:1681:11
#32 0x00000000020ca47b (anonymous
namespace)::ConstStructBuilder::Build(clang::APValue const&, clang::RecordDecl
const*, bool, clang::CXXRecordDecl const*, clang::CharUnits)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:829:15
#33 0x00000000020c4382 (anonymous
namespace)::ConstStructBuilder::BuildStruct(clang::CodeGen::ConstantEmitter&,
clang::APValue const&, clang::QualType)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:879:7
#34 0x00000000020c4382
clang::CodeGen::ConstantEmitter::tryEmitPrivate(clang::APValue const&,
clang::QualType)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:2119:12
#35 0x00000000020c3efa
clang::CodeGen::ConstantEmitter::tryEmitPrivateForMemory(clang::APValue const&,
clang::QualType)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:1681:11
#36 0x00000000020c3efa
clang::CodeGen::ConstantEmitter::tryEmitPrivateForVarInit(clang::VarDecl
const&)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:1634:12
#37 0x00000000020c5b1c
clang::CodeGen::ConstantEmitter::markIfFailed(llvm::Constant*)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/ConstantEmitter.h:162:10
#38 0x00000000020c5b1c
clang::CodeGen::ConstantEmitter::tryEmitForInitializer(clang::VarDecl const&)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:1409:10
#39 0x000000000215e326
clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*,
bool)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:4311:10
#40 0x0000000002157295
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:0:12
#41 0x0000000002160b02 clang::Decl::getKind() const
/home/ryan_mansfield/llvm/llvm-project/clang/include/clang/AST/DeclBase.h:433:51
#42 0x0000000002160b02 clang::DecompositionDecl::classof(clang::Decl const*)
/home/ryan_mansfield/llvm/llvm-project/clang/include/clang/AST/DeclCXX.h:3916:62
#43 0x0000000002160b02 llvm::isa_impl<clang::DecompositionDecl, clang::Decl,
void>::doit(clang::Decl const&)
/home/ryan_mansfield/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:58:12
#44 0x0000000002160b02 llvm::isa_impl_cl<clang::DecompositionDecl, clang::Decl
const*>::doit(clang::Decl const*)
/home/ryan_mansfield/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:105:12
#45 0x0000000002160b02 llvm::isa_impl_wrap<clang::DecompositionDecl,
clang::Decl const*, clang::Decl const*>::doit(clang::Decl const* const&)
/home/ryan_mansfield/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:131:12
#46 0x0000000002160b02 llvm::isa_impl_wrap<clang::DecompositionDecl,
clang::Decl* const, clang::Decl const*>::doit(clang::Decl* const&)
/home/ryan_mansfield/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:121:12
#47 0x0000000002160b02 bool llvm::isa<clang::DecompositionDecl,
clang::Decl*>(clang::Decl* const&)
/home/ryan_mansfield/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:142:10
#48 0x0000000002160b02 llvm::cast_retty<clang::DecompositionDecl,
clang::Decl*>::ret_type llvm::dyn_cast<clang::DecompositionDecl,
clang::Decl>(clang::Decl*)
/home/ryan_mansfield/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:345:10
#49 0x0000000002160b02
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:5664:20
#50 0x0000000002c9180f (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp:169:73
#51 0x0000000002c8e266
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:217:11
#52 0x0000000003738c74 clang::ParseAST(clang::Sema&, bool, bool)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/Parse/ParseAST.cpp:162:11
#53 0x00000000026471c1 clang::FrontendAction::Execute()
/home/ryan_mansfield/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:953:10
#54 0x00000000025ce093 llvm::Error::getPtr() const
/home/ryan_mansfield/llvm/llvm-project/llvm/include/llvm/Support/Error.h:274:42
#55 0x00000000025ce093 llvm::Error::operator bool()
/home/ryan_mansfield/llvm/llvm-project/llvm/include/llvm/Support/Error.h:236:16
#56 0x00000000025ce093
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:965:23
#57 0x00000000026f11bb
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/ryan_mansfield/llvm/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:25
#58 0x00000000009a953a cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
/home/ryan_mansfield/llvm/llvm-project/clang/tools/driver/cc1_main.cpp:246:15
#59 0x00000000009a6eea ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
/home/ryan_mansfield/llvm/llvm-project/clang/tools/driver/driver.cpp:338:12
#60 0x00000000009a6c41 main
/home/ryan_mansfield/llvm/llvm-project/clang/tools/driver/driver.cpp:415:12
#61 0x00007ffff64e8bf7 __libc_start_main
/build/glibc-S7xCS9/glibc-2.27/csu/../csu/libc-start.c:344:0
#62 0x00000000009a3d7a _start
(/home/ryan_mansfield/llvm/llvm-project/build/bin/clang-13+0x9a3d7a)
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
64d951be61aa7d69ad10cc87796151156da7d7ce)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/ryan_mansfield/llvm/llvm-project/build/bin
clang-13: note: diagnostic msg: Error generating preprocessed source(s) - no
preprocessable inputs.


Bisecting the change that introduced the assertion is:

commit be10b7e43a3a10fbd3244f826591f3f65c0b7e21 (HEAD -> main)
Author: Wyatt Childers <wchilders at lock3software.com>
Date:   Fri Mar 20 14:57:56 2020 -0700

    Use values cached in ConstantExprs for expression evaluation where
    present.

    No functionality change intended.

    Differential Revision: https://reviews.llvm.org/D76438

-- 
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/20210430/88ae82f9/attachment-0001.html>


More information about the llvm-bugs mailing list