https://llvm.org/bugs/show_bug.cgi?id=30481
Bug ID: 30481 Summary: clang crashes on code with int as first argument to printf: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed Product: clang Version: trunk Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: Frontend Assignee: unassignedclangb...@nondot.org Reporter: s...@cs.ucdavis.edu CC: llvm-bugs@lists.llvm.org Classification: Unclassified It doesn't crash 3.8.x, which also gives proper warnings. $ clang -v clang version 4.0.0 (trunk 282005) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/local/clang-trunk/bin Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.3 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.1.1 Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9 Candidate multilib: .;@m64 Candidate multilib: 32;@m32 Candidate multilib: x32;@mx32 Selected multilib: .;@m64 $ $ clang-3.8 -c small.c small.c:5:11: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *' [-Wint-conversion] printf (1 > 0); ^~~~~ small.c:1:25: note: passing argument to parameter here int printf (const char *, ...); ^ small.c:5:11: warning: format string is not a string literal (potentially insecure) [-Wformat-security] printf (1 > 0); ^~~~~ 2 warnings generated. $ $ clang -c small.c small.c:5:11: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *' [-Wint-conversion] printf (1 > 0); ^~~~~ small.c:1:25: note: passing argument to parameter here int printf (const char *, ...); ^ clang-4.0: /tmp/llvm-builder/llvm-source-trunk/include/llvm/Support/Casting.h:237: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = clang::UnaryOperator; Y = const clang::Expr; typename llvm::cast_retty<X, Y*>::ret_type = const clang::UnaryOperator*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed. #0 0x0000000001e7b255 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/local/clang-trunk/bin/clang-4.0+0x1e7b255) #1 0x0000000001e7933e llvm::sys::RunSignalHandlers() (/usr/local/clang-trunk/bin/clang-4.0+0x1e7933e) #2 0x0000000001e794a0 SignalHandler(int) (/usr/local/clang-trunk/bin/clang-4.0+0x1e794a0) #3 0x00007f8e0da57340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340) #4 0x00007f8e0c848cc9 gsignal /build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0 #5 0x00007f8e0c84c0d8 abort /build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0 #6 0x00007f8e0c841b86 __assert_fail_base /build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0 #7 0x00007f8e0c841c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32) #8 0x0000000000a1f882 llvm::cast_retty<clang::analyze_printf::PrintfConversionSpecifier, clang::analyze_format_string::ConversionSpecifier const>::ret_type llvm::cast<clang::analyze_printf::PrintfConversionSpecifier, clang::analyze_format_string::ConversionSpecifier const>(clang::analyze_format_string::ConversionSpecifier const&) [clone .part.878] (/usr/local/clang-trunk/bin/clang-4.0+0xa1f882) #9 0x0000000002c723d2 checkFormatStringExpr(clang::Sema&, clang::Expr const*, llvm::ArrayRef<clang::Expr const*>, bool, unsigned int, unsigned int, clang::Sema::FormatStringType, clang::Sema::VariadicCallType, bool, llvm::SmallBitVector&, (anonymous namespace)::UncoveredArgHandler&, llvm::APSInt) (/usr/local/clang-trunk/bin/clang-4.0+0x2c723d2) #10 0x0000000002c72da3 clang::Sema::CheckFormatArguments(llvm::ArrayRef<clang::Expr const*>, bool, unsigned int, unsigned int, clang::Sema::FormatStringType, clang::Sema::VariadicCallType, clang::SourceLocation, clang::SourceRange, llvm::SmallBitVector&) (/usr/local/clang-trunk/bin/clang-4.0+0x2c72da3) #11 0x0000000002c73387 clang::Sema::CheckFormatArguments(clang::FormatAttr const*, llvm::ArrayRef<clang::Expr const*>, bool, clang::Sema::VariadicCallType, clang::SourceLocation, clang::SourceRange, llvm::SmallBitVector&) (/usr/local/clang-trunk/bin/clang-4.0+0x2c73387) #12 0x0000000002c79739 clang::Sema::checkCall(clang::NamedDecl*, clang::FunctionProtoType const*, llvm::ArrayRef<clang::Expr const*>, bool, clang::SourceLocation, clang::SourceRange, clang::Sema::VariadicCallType) (/usr/local/clang-trunk/bin/clang-4.0+0x2c79739) #13 0x0000000002c7a3fe clang::Sema::CheckFunctionCall(clang::FunctionDecl*, clang::CallExpr*, clang::FunctionProtoType const*) (/usr/local/clang-trunk/bin/clang-4.0+0x2c7a3fe) #14 0x0000000002dfa286 clang::Sema::BuildResolvedCallExpr(clang::Expr*, clang::NamedDecl*, clang::SourceLocation, llvm::ArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool) (/usr/local/clang-trunk/bin/clang-4.0+0x2dfa286) #15 0x0000000002dfacfd clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool) (/usr/local/clang-trunk/bin/clang-4.0+0x2dfacfd) #16 0x0000000002a547d3 clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) (/usr/local/clang-trunk/bin/clang-4.0+0x2a547d3) #17 0x0000000002a4eff8 clang::Parser::ParseCastExpression(bool, bool, bool&, clang::Parser::TypeCastState) (/usr/local/clang-trunk/bin/clang-4.0+0x2a4eff8) #18 0x0000000002a51e1d clang::Parser::ParseCastExpression(bool, bool, clang::Parser::TypeCastState) (/usr/local/clang-trunk/bin/clang-4.0+0x2a51e1d) #19 0x0000000002a51ea9 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/usr/local/clang-trunk/bin/clang-4.0+0x2a51ea9) #20 0x0000000002a51f29 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/usr/local/clang-trunk/bin/clang-4.0+0x2a51f29) #21 0x0000000002a93316 clang::Parser::ParseExprStatement() (/usr/local/clang-trunk/bin/clang-4.0+0x2a93316) #22 0x0000000002a9075f clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) (/usr/local/clang-trunk/bin/clang-4.0+0x2a9075f) #23 0x0000000002a9093e clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*) (/usr/local/clang-trunk/bin/clang-4.0+0x2a9093e) #24 0x0000000002a952b9 clang::Parser::ParseCompoundStatementBody(bool) (/usr/local/clang-trunk/bin/clang-4.0+0x2a952b9) #25 0x0000000002a97af9 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/usr/local/clang-trunk/bin/clang-4.0+0x2a97af9) #26 0x0000000002a138e7 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/usr/local/clang-trunk/bin/clang-4.0+0x2a138e7) #27 0x0000000002a33c3d clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/usr/local/clang-trunk/bin/clang-4.0+0x2a33c3d) #28 0x0000000002a0ef69 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/usr/local/clang-trunk/bin/clang-4.0+0x2a0ef69) #29 0x0000000002a0f621 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) [clone .part.223] (/usr/local/clang-trunk/bin/clang-4.0+0x2a0f621) #30 0x0000000002a0f65f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/usr/local/clang-trunk/bin/clang-4.0+0x2a0f65f) #31 0x0000000002a14228 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/usr/local/clang-trunk/bin/clang-4.0+0x2a14228) #32 0x0000000002a14d72 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) (/usr/local/clang-trunk/bin/clang-4.0+0x2a14d72) #33 0x0000000002a0c283 clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/clang-trunk/bin/clang-4.0+0x2a0c283) #34 0x000000000261ed3e clang::CodeGenAction::ExecuteAction() (/usr/local/clang-trunk/bin/clang-4.0+0x261ed3e) #35 0x000000000231a10e clang::FrontendAction::Execute() (/usr/local/clang-trunk/bin/clang-4.0+0x231a10e) #36 0x00000000022ef746 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/clang-trunk/bin/clang-4.0+0x22ef746) #37 0x00000000023a9112 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/local/clang-trunk/bin/clang-4.0+0x23a9112) #38 0x0000000000b8a450 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/local/clang-trunk/bin/clang-4.0+0xb8a450) #39 0x0000000000b347ff main (/usr/local/clang-trunk/bin/clang-4.0+0xb347ff) #40 0x00007f8e0c833ec5 __libc_start_main /build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0 #41 0x0000000000b865ae _start (/usr/local/clang-trunk/bin/clang-4.0+0xb865ae) Stack dump: 0. Program arguments: /usr/local/clang-trunk/bin/clang-4.0 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name small.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -coverage-notes-file /home/su/20160916-clang-trunk-O3-m32-build-233228/small.gcno -resource-dir /usr/local/clang-trunk/bin/../lib/clang/4.0.0 -internal-isystem /usr/local/include -internal-isystem /usr/local/clang-trunk/bin/../lib/clang/4.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /home/su/20160916-clang-trunk-O3-m32-build-233228 -ferror-limit 19 -fmessage-length 163 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o small.o -x c small.c 1. small.c:5:16: current parser token ')' 2. small.c:4:1: parsing function body 'foo' 3. small.c:4:1: in compound statement ('{}') clang-4.0: error: unable to execute command: Aborted (core dumped) clang-4.0: error: clang frontend command failed due to signal (use -v to see invocation) clang version 4.0.0 (trunk 282005) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/local/clang-trunk/bin clang-4.0: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script. clang-4.0: note: diagnostic msg: ******************** PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-4.0: note: diagnostic msg: /tmp/small-25cfe8.c clang-4.0: note: diagnostic msg: /tmp/small-25cfe8.sh clang-4.0: note: diagnostic msg: ******************** $ ------------------------------------- int printf (const char *, ...); void foo () { printf (1 > 0); } -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs