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 28101 - clang crashes on invalid C++ code (with -std=c++11): Assertion `!Lookup.empty() && Lookup.size() <= 2 && "more than two lookup results for field name"' failed
Summary: clang crashes on invalid C++ code (with -std=c++11): Assertion `!Lookup.empty...
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:
Depends on:
Blocks:
 
Reported: 2016-06-13 00:39 PDT by Zhendong Su
Modified: 2016-06-13 01:18 PDT (History)
3 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-06-13 00:39:00 PDT
The current clang trunk crashes when compiling the following C++ test case with -std=c++11 on x86_64-linux-gnu in both 32-bit and 64-bit modes. 

It also affects 3.6.x to 3.8.x, but is (mistakenly) accepted by 3.5.x. 


$ clang++ -v
clang version 3.9.0 (trunk 272507)
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.5.2 -std=c++11 -c small.cpp
$
$ clang++ -std=c++11 -c small.cpp
clang-3.9: /tmp/llvm-builder/llvm-source-trunk/tools/clang/lib/Sema/SemaDeclCXX.cpp:11558: clang::ExprResult clang::Sema::BuildCXXDefaultInitExpr(clang::SourceLocation, clang::FieldDecl*): Assertion `!Lookup.empty() && Lookup.size() <= 2 && "more than two lookup results for field name"' failed.
#0 0x0000000001e23f35 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/local/clang-trunk/bin/clang-3.9+0x1e23f35)
#1 0x0000000001e21dc6 llvm::sys::RunSignalHandlers() (/usr/local/clang-trunk/bin/clang-3.9+0x1e21dc6)
#2 0x0000000001e21fe4 SignalHandler(int) (/usr/local/clang-trunk/bin/clang-3.9+0x1e21fe4)
#3 0x00007ffc8f68f340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007ffc8e8adcc9 gsignal /build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007ffc8e8b10d8 abort /build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007ffc8e8a6b86 __assert_fail_base /build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007ffc8e8a6c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x0000000002c4dff7 clang::Sema::BuildCXXDefaultInitExpr(clang::SourceLocation, clang::FieldDecl*) (/usr/local/clang-trunk/bin/clang-3.9+0x2c4dff7)
#9 0x0000000002c6b2b5 CollectFieldInitializer(clang::Sema&, (anonymous namespace)::BaseAndFieldInfo&, clang::FieldDecl*, clang::IndirectFieldDecl*) (/usr/local/clang-trunk/bin/clang-3.9+0x2c6b2b5)
#10 0x0000000002c8886b clang::Sema::SetCtorInitializers(clang::CXXConstructorDecl*, bool, llvm::ArrayRef<clang::CXXCtorInitializer*>) (/usr/local/clang-trunk/bin/clang-3.9+0x2c8886b)
#11 0x0000000002c89862 clang::Sema::ActOnMemInitializers(clang::Decl*, clang::SourceLocation, llvm::ArrayRef<clang::CXXCtorInitializer*>, bool) (/usr/local/clang-trunk/bin/clang-3.9+0x2c89862)
#12 0x0000000002f83547 clang::Sema::InstantiateMemInitializers(clang::CXXConstructorDecl*, clang::CXXConstructorDecl const*, clang::MultiLevelTemplateArgumentList const&) (/usr/local/clang-trunk/bin/clang-3.9+0x2f83547)
#13 0x0000000002f88312 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/usr/local/clang-trunk/bin/clang-3.9+0x2f88312)
#14 0x0000000002f86b07 clang::Sema::PerformPendingInstantiations(bool) (/usr/local/clang-trunk/bin/clang-3.9+0x2f86b07)
#15 0x0000000002b46e5d clang::Sema::ActOnEndOfTranslationUnit() (/usr/local/clang-trunk/bin/clang-3.9+0x2b46e5d)
#16 0x000000000293cbd1 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) (/usr/local/clang-trunk/bin/clang-3.9+0x293cbd1)
#17 0x00000000029340fb clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/clang-trunk/bin/clang-3.9+0x29340fb)
#18 0x00000000025d01fe clang::CodeGenAction::ExecuteAction() (/usr/local/clang-trunk/bin/clang-3.9+0x25d01fe)
#19 0x000000000229a76e clang::FrontendAction::Execute() (/usr/local/clang-trunk/bin/clang-3.9+0x229a76e)
#20 0x00000000022700e6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/clang-trunk/bin/clang-3.9+0x22700e6)
#21 0x00000000023284c2 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/local/clang-trunk/bin/clang-3.9+0x23284c2)
#22 0x0000000000aeef38 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/local/clang-trunk/bin/clang-3.9+0xaeef38)
#23 0x0000000000aa3134 main (/usr/local/clang-trunk/bin/clang-3.9+0xaa3134)
#24 0x00007ffc8e898ec5 __libc_start_main /build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#25 0x0000000000aeafa4 _start (/usr/local/clang-trunk/bin/clang-3.9+0xaeafa4)
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 -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /data2 -ferror-limit 19 -fmessage-length 154 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o small.o -x c++ small.cpp
1.      <eof> parser at end of file
2.      small.cpp:5:3: instantiating function definition 'A<int>::A'
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 272507)
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-e91dee.cpp
clang-3.9: note: diagnostic msg: /tmp/small-e91dee.sh
clang-3.9: note: diagnostic msg:

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


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


template < typename T >
class A
{
public:
  A (void *) {}
  T (A < T >) {};  // should have been: T foo (A < T >) {};
};

A < int > foo ()
{ 
  return new int;
}