[llvm-bugs] [Bug 37328] New: blocks: Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file include/llvm/Support/Casting.h, line 255.

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 3 10:12:02 PDT 2018


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

            Bug ID: 37328
           Summary: blocks: Assertion failed: (isa<X>(Val) && "cast<Ty>()
                    argument of incompatible type!"), function cast, file
                    include/llvm/Support/Casting.h, line 255.
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: dimitry at andric.com
                CC: llvm-bugs at lists.llvm.org

Originally reported in https://bugs.freebsd.org/227941, using a C++ test case
with blocks support turned on, giving an assertion:

Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"),
function cast, file include/llvm/Support/Casting.h, line 255.

Minimized test case:

// clang -cc1 -triple x86_64-- -S -fblocks bug227941-min.cpp
class a {
public:
  template <class b> a(b);
};
class {
public:
  int c(a);
} d;
void f() {
  __attribute__((__blocks__(byref))) int e = d.c([] {});
}

Backtrace:

#0  thr_kill () at thr_kill.S:3
#1  0x0000000806dda084 in __raise (s=6) at /usr/src/lib/libc/gen/raise.c:54
#2  0x0000000806dd9ff9 in abort () at /usr/src/lib/libc/stdlib/abort.c:67
#3  0x0000000806e57431 in __assert (func=<optimized out>, file=<optimized out>,
line=<optimized out>, failedexpr=<optimized out>) at
/usr/src/lib/libc/gen/assert.c:53
#4  0x0000000003d1eac9 in llvm::cast<clang::Expr, clang::Stmt const>
(Val=0x8079db3c0) at
/home/dim/src/llvm/trunk/include/llvm/Support/Casting.h:255
#5  0x0000000003d675f7 in isCapturedBy (var=..., e=0x8079db748) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGDecl.cpp:1280
#6  0x0000000003d67606 in isCapturedBy (var=..., e=0x8079de3c8) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGDecl.cpp:1280
#7  0x0000000003d67606 in isCapturedBy (var=..., e=0x8079de400) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGDecl.cpp:1280
#8  0x0000000003d67606 in isCapturedBy (var=..., e=0x8079de828) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGDecl.cpp:1280
#9  0x0000000003d67606 in isCapturedBy (var=..., e=0x8079db868) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGDecl.cpp:1280
#10 0x0000000003d67606 in isCapturedBy (var=..., e=0x8079de860) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGDecl.cpp:1280
#11 0x0000000003d65ba9 in clang::CodeGen::CodeGenFunction::EmitAutoVarInit
(this=0x7fffffff6598, emission=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGDecl.cpp:1345
#12 0x0000000003d614d5 in clang::CodeGen::CodeGenFunction::EmitAutoVarDecl
(this=0x7fffffff6598, D=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGDecl.cpp:956
#13 0x0000000003d60d1a in clang::CodeGen::CodeGenFunction::EmitVarDecl
(this=0x7fffffff6598, D=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGDecl.cpp:183
#14 0x0000000003d60a62 in clang::CodeGen::CodeGenFunction::EmitDecl
(this=0x7fffffff6598, D=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGDecl.cpp:132
#15 0x0000000003d19b46 in clang::CodeGen::CodeGenFunction::EmitDeclStmt
(this=0x7fffffff6598, S=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGStmt.cpp:1113
#16 0x0000000003d0da5e in clang::CodeGen::CodeGenFunction::EmitSimpleStmt
(this=0x7fffffff6598, S=0x8079de878) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGStmt.cpp:354
#17 0x0000000003d0ce3e in clang::CodeGen::CodeGenFunction::EmitStmt
(this=0x7fffffff6598, S=0x8079de878, Attrs=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGStmt.cpp:53
#18 0x0000000003d1a67c in
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope
(this=0x7fffffff6598, S=..., GetLast=false, AggSlot=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGStmt.cpp:390
#19 0x0000000003cc3e02 in clang::CodeGen::CodeGenFunction::EmitFunctionBody
(this=0x7fffffff6598, Args=..., Body=0x8079de890) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenFunction.cpp:1195
#20 0x0000000003cc4863 in clang::CodeGen::CodeGenFunction::GenerateCode
(this=0x7fffffff6598, GD=..., Fn=0x8078ac088, FnInfo=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenFunction.cpp:1360
#21 0x0000000003b3685d in
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition (this=0x807850a00,
GD=..., GV=0x8078ac088) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenModule.cpp:3635
#22 0x0000000003b2ec75 in clang::CodeGen::CodeGenModule::EmitGlobalDefinition
(this=0x807850a00, GD=..., GV=0x0) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenModule.cpp:2300
#23 0x0000000003b3481f in clang::CodeGen::CodeGenModule::EmitGlobal
(this=0x807850a00, GD=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenModule.cpp:2076
#24 0x0000000003b3a1a0 in clang::CodeGen::CodeGenModule::EmitTopLevelDecl
(this=0x807850a00, D=0x807984f58) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenModule.cpp:4370
#25 0x00000000046dc9f2 in (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl (this=0x8078b0c00, DG=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/ModuleBuilder.cpp:160
#26 0x00000000046d4a79 in clang::BackendConsumer::HandleTopLevelDecl
(this=0x8078a9300, D=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenAction.cpp:168
#27 0x0000000005167cda in clang::ParseAST (S=..., PrintStats=false,
SkipFunctionBodies=false) at
/home/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseAST.cpp:156
#28 0x00000000044e29d1 in clang::ASTFrontendAction::ExecuteAction
(this=0x8078263c0) at
/home/dim/src/llvm/trunk/tools/clang/lib/Frontend/FrontendAction.cpp:1005
#29 0x00000000046d0759 in clang::CodeGenAction::ExecuteAction
(this=0x8078263c0) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenAction.cpp:1043
#30 0x00000000044e1f50 in clang::FrontendAction::Execute (this=0x8078263c0) at
/home/dim/src/llvm/trunk/tools/clang/lib/Frontend/FrontendAction.cpp:904
#31 0x000000000434f42f in clang::CompilerInstance::ExecuteAction
(this=0x8078a9000, Act=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/Frontend/CompilerInstance.cpp:989
#32 0x00000000046c2346 in clang::ExecuteCompilerInvocation (Clang=0x8078a9000)
at
/home/dim/src/llvm/trunk/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:255
#33 0x0000000001958017 in cc1_main (Argv=..., Argv0=0x7fffffffe928
"/home/dim/obj/clang-trunk-r331459/bin/clang", MainAddr=0x1944280
<GetExecutablePath(char const*, bool)>) at
/home/dim/src/llvm/trunk/tools/clang/tools/driver/cc1_main.cpp:222
#34 0x0000000001947472 in ExecuteCC1Tool (argv=..., Tool=...) at
/home/dim/src/llvm/trunk/tools/clang/tools/driver/driver.cpp:310
#35 0x000000000194549a in main (argc_=7, argv_=0x7fffffffe688) at
/home/dim/src/llvm/trunk/tools/clang/tools/driver/driver.cpp:382
(gdb) frame 5
#5  0x0000000003d675f7 in isCapturedBy (var=..., e=0x8079db748) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGDecl.cpp:1280
1280        if (isCapturedBy(var, cast<Expr>(SubStmt)))
(gdb) print var
$1 = (const clang::VarDecl &) @0x8079db028: {<clang::DeclaratorDecl> =
{<clang::ValueDecl> = {<clang::NamedDecl> = {<clang::Decl> = {_vptr$Decl =
0x6d00448 <vtable for clang::VarDecl+16>, NextInContextAndBits = {Value =
34487513552}, DeclCtx = {Val = {Value = 34487160728}}, Loc = {ID = 196},
DeclKind = 56, InvalidDecl = 0, HasAttrs = 1, Implicit = 0, Used = 0,
Referenced = 0, TopLevelDeclInObjCContainer = 0p, static StatisticsEnabled =
false, Access = 3, FromASTFile = 0, IdentifierNamespace = 32,
CacheValidAndLinkage = 0}, Name = {static NumNameKinds = 11, Ptr =
34487397224}}, DeclType = {Value = {Value = 34486547424}}}, DeclInfo = {Val =
{Value = 34487513104}}, InnerLocStart = {ID = 157}},
<clang::Redeclarable<clang::VarDecl>> = {RedeclLink = {Next = {Val = {Value =
34487513129}}}, First = 0x8079db028}, Init = {Val = {Value = 34487527520}},
{AllBits = 0, VarDeclBits = {SClass = 0, TSCSpec = 0, InitStyle = 0},
ParmVarDeclBits = {HasInheritedDefaultArg = 0, DefaultArgKind = 0,
IsKNRPromoted = 0, IsObjCMethodParam = 0, ScopeDepthOrObjCQuals = 0,
ParameterIndex = 0}, NonParmVarDeclBits = {IsThisDeclarationADemotedDefinition
= 0, ExceptionVar = 0, NRVOVariable = 0, CXXForRangeDecl = 0, ObjCForDecl = 0,
ARCPseudoStrong = 0, IsInline = 0, IsInlineSpecified = 0, IsConstexpr = 0,
IsInitCapture = 0, PreviousDeclInSameBlockScope = 0, ImplicitParamKind = 0}}}
(gdb) print *SubStmt
$3 = {{StmtBits = {sClass = 9}, CompoundStmtBits = {NumStmts = 0}, IfStmtBits =
{IsConstexpr = 0}, ExprBits = {ValueKind = 0, ObjectKind = 0, TypeDependent =
0, ValueDependent = 0, InstantiationDependent = 0,
ContainsUnexpandedParameterPack = 0}, CharacterLiteralBits = {Kind = 0},
FloatingLiteralBits = {Semantics = 0, IsExact = 0},
UnaryExprOrTypeTraitExprBits = {Kind = 0, IsType = 0}, DeclRefExprBits =
{HasQualifier = 0, HasTemplateKWAndArgsInfo = 0, HasFoundDecl = 0,
HadMultipleCandidates = 0, RefersToEnclosingVariableOrCapture = 0},
CastExprBits = {Kind = 0, BasePathSize = 0}, CallExprBits = {NumPreArgs = 0},
ExprWithCleanupsBits = {CleanupsHaveSideEffects = 0, NumObjects = 0},
PseudoObjectExprBits = {NumSubExprs = 0, ResultIndex = 0}, OpaqueValueExprBits
= {IsUnique = 0}, ObjCIndirectCopyRestoreExprBits = {ShouldCopy = 0},
InitListExprBits = {HadArrayRangeDesignator = 0}, TypeTraitExprBits = {Kind =
0, Value = 0, NumArgs = 0}, CoawaitBits = {IsImplicit = 0}}, static
StatisticsEnabled = false}

-- 
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/20180503/11deec69/attachment.html>


More information about the llvm-bugs mailing list