[llvm-bugs] [Bug 42707] New: Assertion fires in CastExpr::CastConsistency

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 22 03:04:51 PDT 2019


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

            Bug ID: 42707
           Summary: Assertion fires in CastExpr::CastConsistency
           Product: clang
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: OpenCL
          Assignee: unassignedclangbugs at nondot.org
          Reporter: marco.antognini at arm.com
                CC: anastasia.stulova at arm.com, llvm-bugs at lists.llvm.org

Created attachment 22267
  --> https://bugs.llvm.org/attachment.cgi?id=22267&action=edit
OpenCL reproducer

Clang crashes when running the attached program using

    clang -cc1 -emit-llvm -o - test.cl -cl-std=c++

I believe this crash was introduced with D62584 aka [OpenCL][PR42033] Fix addr
space deduction with template parameters.

The issue is present on trunk and on the 9.x branch.

Here is the output & stacktrace:

test.cl:26:9: error: variable 'f' with type '__generic auto &' has incompatible
initializer of type 'Foo'
  auto& f = p.first; // expected-error{{variable 'f' with type '__generic auto
&' has incompatible initializer of type 'Foo'}}
        ^   ~~~~~~~
clang: /work/checkouts/upstreams/llvm/llvm-project/clang/lib/AST/Expr.cpp:1813:
bool clang::CastExpr::CastConsistency() const: Assertion `!Ty.isNull() &&
!SETy.isNull() && Ty.getAddressSpace() != SETy.getAddressSpace()' failed.
Stack dump:
0.      Program arguments: clang -cc1 -emit-llvm -o - test.cl -cl-std=c++
1.      test.cl:27:21: current parser token ';'
2.      test.cl:24:22: parsing function body 'foobar'
3.      test.cl:24:22: in compound statement ('{}')
 #0 0x00007fb64fa8c6b9 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/work/checkouts/upstreams/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:533:11
 #1 0x00007fb64fa8c869 PrintStackTraceSignalHandler(void*)
/work/checkouts/upstreams/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:594:1
 #2 0x00007fb64fa8b0d6 llvm::sys::RunSignalHandlers()
/work/checkouts/upstreams/llvm/llvm-project/llvm/lib/Support/Signals.cpp:67:5
 #3 0x00007fb64fa8cf3b SignalHandler(int)
/work/checkouts/upstreams/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:385:1
 #4 0x00007fb64ed62390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
 #5 0x00007fb64c0ef428 raise (/lib/x86_64-linux-gnu/libc.so.6+0x35428)
 #6 0x00007fb64c0f102a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a)
 #7 0x00007fb64c0e7bd7 (/lib/x86_64-linux-gnu/libc.so.6+0x2dbd7)
 #8 0x00007fb64c0e7c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
 #9 0x00007fb649dd7630 clang::CastExpr::CastConsistency() const
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/AST/Expr.cpp:1814:5
#10 0x00007fb649b45597 clang::CastExpr::CastExpr(clang::Stmt::StmtClass,
clang::QualType, clang::ExprValueKind, clang::CastKind, clang::Expr*, unsigned
int)
/work/checkouts/upstreams/llvm/llvm-project/clang/include/clang/AST/Expr.h:3154:5
#11 0x00007fb649dee3f2
clang::ImplicitCastExpr::ImplicitCastExpr(clang::QualType, clang::CastKind,
clang::Expr*, unsigned int, clang::ExprValueKind)
/work/checkouts/upstreams/llvm/llvm-project/clang/include/clang/AST/Expr.h:3251:75
#12 0x00007fb649dd8175 clang::ImplicitCastExpr::Create(clang::ASTContext
const&, clang::QualType, clang::CastKind, clang::Expr*,
llvm::SmallVector<clang::CXXBaseSpecifier*, 4u> const*, clang::ExprValueKind)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/AST/Expr.cpp:1987:5
#13 0x00007fb6478d5bd0 clang::Sema::ImpCastExprToType(clang::Expr*,
clang::QualType, clang::CastKind, clang::ExprValueKind,
llvm::SmallVector<clang::CXXBaseSpecifier*, 4u> const*,
clang::Sema::CheckedConversionKind)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Sema/Sema.cpp:536:10
#14 0x00007fb6480b842c
clang::Sema::PerformQualificationConversion(clang::Expr*, clang::QualType,
clang::ExprValueKind, clang::Sema::CheckedConversionKind)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Sema/SemaInit.cpp:7368:10
#15 0x00007fb6480ba34b clang::InitializationSequence::Perform(clang::Sema&,
clang::InitializedEntity const&, clang::InitializationKind const&,
llvm::MutableArrayRef<clang::Expr*>, clang::QualType*)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Sema/SemaInit.cpp:7766:19
#16 0x00007fb647a690cb clang::Sema::AddInitializerToDecl(clang::Decl*,
clang::Expr*, bool)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Sema/SemaDecl.cpp:11518:33
#17 0x00007fb6487178ae
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/ParseDecl.cpp:2364:5
#18 0x00007fb648715f9e clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/ParseDecl.cpp:2098:9
#19 0x00007fb6487111a2
clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&, bool,
clang::Parser::ForRangeInit*)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/ParseDecl.cpp:1823:10
#20 0x00007fb648710e36
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/ParseDecl.cpp:1763:12
#21 0x00007fb6487dabe3
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/ParseStmt.cpp:213:29
#22 0x00007fb6487da6be
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/ParseStmt.cpp:106:20
#23 0x00007fb6487e2223 clang::Parser::ParseCompoundStatementBody(bool)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/ParseStmt.cpp:1063:11
#24 0x00007fb6487e309a clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/ParseStmt.cpp:2076:21
#25 0x00007fb648807e94
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/Parser.cpp:1326:3
#26 0x00007fb648715b94 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/ParseDecl.cpp:2040:11
#27 0x00007fb648806dc5
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/Parser.cpp:1095:10
#28 0x00007fb6488063e0
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/Parser.cpp:1111:12
#29 0x00007fb648805cc0
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/Parser.cpp:931:12
#30 0x00007fb64880401c
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/Parser.cpp:682:12
#31 0x00007fb6486f6461 clang::ParseAST(clang::Sema&, bool, bool)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/ParseAST.cpp:158:16
#32 0x00007fb64d6e5bf2 clang::ASTFrontendAction::ExecuteAction()
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1043:1
#33 0x00007fb64e4a105f clang::CodeGenAction::ExecuteAction()
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1060:1
#34 0x00007fb64d6e55a1 clang::FrontendAction::Execute()
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:938:7
#35 0x00007fb64d663587
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:944:23
#36 0x00007fb64d2c6632
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:291:8
#37 0x000000000024048f cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
/work/checkouts/upstreams/llvm/llvm-project/clang/tools/driver/cc1_main.cpp:249:13
#38 0x00000000002344c1 ExecuteCC1Tool(llvm::ArrayRef<char const*>,
llvm::StringRef)
/work/checkouts/upstreams/llvm/llvm-project/clang/tools/driver/driver.cpp:309:5
#39 0x0000000000233851 main
/work/checkouts/upstreams/llvm/llvm-project/clang/tools/driver/driver.cpp:381:5
#40 0x00007fb64c0da830 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x20830)
#41 0x0000000000233029 _start
(/work/checkouts/upstreams/llvm/build/bin/clang-9+0x233029)
fish: 'clang -cc1 -emit-llvm -o - te...' terminated by signal SIGABRT (Abort)

-- 
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/20190722/23d366fe/attachment.html>


More information about the llvm-bugs mailing list