LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 27144 - clang crashes on valid C++ code
Summary: clang crashes on valid C++ code
Status: NEW
Alias: None
Product: clang
Classification: Unclassified
Component: C++ (show other bugs)
Version: trunk
Hardware: PC All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2016-03-30 16:37 PDT by Zhendong Su
Modified: 2020-01-26 09:00 PST (History)
6 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zhendong Su 2016-03-30 16:37:42 PDT
The current clang trunk (as well 3.2.x and later) crashes when compiling the following test case on x86_64-linux-gnu in both 32-bit and 64-bit modes. 

This is a regression from 3.1.x.  


$ clang++ -v
clang version 3.9.0 (trunk 264841)
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.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.3.0
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.1 -c small.cpp
$ 
$ clang++ -c small.cpp
clang-3.9: /tmp/llvm-builder/llvm-source-trunk/tools/clang/lib/AST/ExprClassification.cpp:56: Cl clang::Expr::ClassifyImpl(clang::ASTContext&, clang::SourceLocation*) const: Assertion `getValueKind() == VK_LValue' failed.
#0 0x0000000001d5a075 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/local/clang-trunk/bin/clang-3.9+0x1d5a075)
#1 0x0000000001d58006 llvm::sys::RunSignalHandlers() (/usr/local/clang-trunk/bin/clang-3.9+0x1d58006)
#2 0x0000000001d58224 SignalHandler(int) (/usr/local/clang-trunk/bin/clang-3.9+0x1d58224)
#3 0x00007f86dd97e340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007f86dcb9ccc9 gsignal /build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f86dcba00d8 abort /build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f86dcb95b86 __assert_fail_base /build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f86dcb95c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x0000000003276605 clang::Expr::ClassifyImpl(clang::ASTContext&, clang::SourceLocation*) const (/usr/local/clang-trunk/bin/clang-3.9+0x3276605)
#9 0x0000000003276717 clang::Expr::isModifiableLvalue(clang::ASTContext&, clang::SourceLocation*) const (/usr/local/clang-trunk/bin/clang-3.9+0x3276717)
#10 0x0000000002b72819 CheckForModifiableLvalue(clang::Expr*, clang::SourceLocation, clang::Sema&) (/usr/local/clang-trunk/bin/clang-3.9+0x2b72819)
#11 0x0000000002b89e9e clang::Sema::CheckAssignmentOperands(clang::Expr*, clang::ActionResult<clang::Expr*, true>&, clang::SourceLocation, clang::QualType) (/usr/local/clang-trunk/bin/clang-3.9+0x2b89e9e)
#12 0x0000000002b8b0d7 clang::Sema::CreateBuiltinBinOp(clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) (/usr/local/clang-trunk/bin/clang-3.9+0x2b8b0d7)
#13 0x0000000002b8bd0a clang::Sema::BuildBinOp(clang::Scope*, clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) (/usr/local/clang-trunk/bin/clang-3.9+0x2b8bd0a)
#14 0x0000000002b8c02a clang::Sema::ActOnBinOp(clang::Scope*, clang::SourceLocation, clang::tok::TokenKind, clang::Expr*, clang::Expr*) (/usr/local/clang-trunk/bin/clang-3.9+0x2b8c02a)
#15 0x000000000282ace5 clang::Parser::ParseRHSOfBinaryExpression(clang::ActionResult<clang::Expr*, true>, clang::prec::Level) (/usr/local/clang-trunk/bin/clang-3.9+0x282ace5)
#16 0x000000000282a5e9 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/usr/local/clang-trunk/bin/clang-3.9+0x282a5e9)
#17 0x000000000282a659 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/usr/local/clang-trunk/bin/clang-3.9+0x282a659)
#18 0x00000000028674b6 clang::Parser::ParseExprStatement() (/usr/local/clang-trunk/bin/clang-3.9+0x28674b6)
#19 0x000000000286609f clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) (/usr/local/clang-trunk/bin/clang-3.9+0x286609f)
#20 0x00000000028664be clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*) (/usr/local/clang-trunk/bin/clang-3.9+0x28664be)
#21 0x000000000286aa39 clang::Parser::ParseCompoundStatementBody(bool) (/usr/local/clang-trunk/bin/clang-3.9+0x286aa39)
#22 0x000000000286dce5 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/usr/local/clang-trunk/bin/clang-3.9+0x286dce5)
#23 0x00000000027f2471 clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) (/usr/local/clang-trunk/bin/clang-3.9+0x27f2471)
#24 0x00000000027f21ee clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) (/usr/local/clang-trunk/bin/clang-3.9+0x27f21ee)
#25 0x0000000002822bf9 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int, clang::Decl*) (/usr/local/clang-trunk/bin/clang-3.9+0x2822bf9)
#26 0x000000000282391f clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::Parser::ParsedAttributesWithRange&) (/usr/local/clang-trunk/bin/clang-3.9+0x282391f)
#27 0x0000000002805e38 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) (/usr/local/clang-trunk/bin/clang-3.9+0x2805e38)
#28 0x00000000027ea5e4 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/usr/local/clang-trunk/bin/clang-3.9+0x27ea5e4)
#29 0x00000000027ead41 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) [clone .part.228] (/usr/local/clang-trunk/bin/clang-3.9+0x27ead41)
#30 0x00000000027ead7f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/usr/local/clang-trunk/bin/clang-3.9+0x27ead7f)
#31 0x00000000027efb50 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/usr/local/clang-trunk/bin/clang-3.9+0x27efb50)
#32 0x00000000027f0310 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) (/usr/local/clang-trunk/bin/clang-3.9+0x27f0310)
#33 0x00000000027e7a10 clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/clang-trunk/bin/clang-3.9+0x27e7a10)
#34 0x00000000024acb3e clang::CodeGenAction::ExecuteAction() (/usr/local/clang-trunk/bin/clang-3.9+0x24acb3e)
#35 0x000000000219990e clang::FrontendAction::Execute() (/usr/local/clang-trunk/bin/clang-3.9+0x219990e)
#36 0x0000000002172806 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/clang-trunk/bin/clang-3.9+0x2172806)
#37 0x0000000002223692 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/local/clang-trunk/bin/clang-3.9+0x2223692)
#38 0x0000000000abf198 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/local/clang-trunk/bin/clang-3.9+0xabf198)
#39 0x0000000000a7b3dd main (/usr/local/clang-trunk/bin/clang-3.9+0xa7b3dd)
#40 0x00007f86dcb87ec5 __libc_start_main /build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#41 0x0000000000abb204 _start (/usr/local/clang-trunk/bin/clang-3.9+0xabb204)
Stack dump:
0.	Program arguments: /usr/local/clang-trunk/bin/clang-3.9 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name small.cpp -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-file /data2/small.cpp -resource-dir /usr/local/clang-trunk/bin/../lib/clang/3.9.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/backward -internal-isystem /usr/local/include -internal-isystem /usr/local/clang-trunk/bin/../lib/clang/3.9.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /data2 -ferror-limit 19 -fmessage-length 110 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o small.o -x c++ small.cpp 
1.	small.cpp:5:21: current parser token ';'
2.	small.cpp:1:1: parsing struct/union/class body 'A'
3.	small.cpp:4:3: parsing function body 'A'
4.	small.cpp:4:3: in compound statement ('{}')
clang-3.9: error: unable to execute command: Aborted (core dumped)
clang-3.9: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 3.9.0 (trunk 264841)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
clang-3.9: 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-3.9: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-3.9: note: diagnostic msg: /tmp/small-c6a500.cpp
clang-3.9: note: diagnostic msg: /tmp/small-c6a500.sh
clang-3.9: note: diagnostic msg: 

********************
$ 


--------------------------


class A 
{
  A (double x)
  {
    __imag__ x = 0.0;
  }
};
Comment 1 Alexander Kornienko 2019-12-11 05:21:15 PST
This still can be reproduced as of https://github.com/llvm/llvm-project/commit/3bf8558fbb2f3e9348bf1f5aafb64d8095ad6420.

$ cat /tmp/q.cc
class A {
  A(double x) { __imag__ x = 0.0; }
};
$ clang-check /tmp/q.cc --
assert.h assertion failed at clang/lib/AST/ExprClassification.cpp:56 in Cl clang::Expr::ClassifyImpl(clang::ASTContext &, clang::SourceLocation *) const: getValueKind() == VK_LValue
Comment 2 Alexander Kornienko 2019-12-11 05:23:01 PST
*** Bug 28122 has been marked as a duplicate of this bug. ***