[LLVMbugs] [Bug 8801] New: Crash/assertion failure on compiling C++ code

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Dec 17 06:51:02 PST 2010


http://llvm.org/bugs/show_bug.cgi?id=8801

           Summary: Crash/assertion failure on compiling C++ code
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: mike at tedder.cc
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Created an attachment (id=5902)
 --> (http://llvm.org/bugs/attachment.cgi?id=5902)
Source file which causes the assertion

Using the latest trunk for llvm (r122054) and clang (r122056), I am getting the
following assertion when trying to compile a source file:

~/src/delegate $ ~/src/clang/build/Debug+Asserts/bin/clang++ -o d2 delegate.cpp 
clang:
/home/bpoint/src/clang/llvm/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp:1702:
clang::Decl* clang::LocalInstantiationScope::getInstantiationOf(const
clang::Decl*): Assertion `D->isInvalidDecl() && "declaration was not
instantiated in this scope!"' failed.
0  clang           0x00000000023ff981
1  clang           0x00000000023ff774
2  libpthread.so.0 0x00007ff79ea62d80
3  libc.so.6       0x00007ff79dd2df25 gsignal + 53
4  libc.so.6       0x00007ff79dd2f8d6 abort + 390
5  libc.so.6       0x00007ff79dd26755 __assert_fail + 245
6  clang           0x00000000015fb2cf
clang::LocalInstantiationScope::getInstantiationOf(clang::Decl const*) + 235
7  clang           0x000000000162035d
clang::Sema::FindInstantiatedDecl(clang::SourceLocation, clang::NamedDecl*,
clang::MultiLevelTemplateArgumentList const&) + 219
8  clang           0x00000000015f7f85
9  clang           0x0000000001602250
10 clang           0x00000000015fc87c
11 clang           0x00000000015fc1cd
12 clang           0x00000000015fc2ec
13 clang           0x00000000016000a8
14 clang           0x00000000015fc51c
15 clang           0x00000000015fc1cd
16 clang           0x00000000015f8f97
clang::Sema::SubstType(clang::TypeSourceInfo*,
clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation,
clang::DeclarationName) + 241
17 clang           0x00000000016176d1
clang::TemplateDeclInstantiator::VisitTypedefDecl(clang::TypedefDecl*) + 233
18 clang           0x0000000001615349
clang::DeclVisitor<clang::TemplateDeclInstantiator,
clang::Decl*>::Visit(clang::Decl*) + 719
19 clang           0x000000000161d72c clang::Sema::SubstDecl(clang::Decl*,
clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) + 130
20 clang           0x00000000015f7fdf
21 clang           0x0000000001603ce9
22 clang           0x00000000015fce0c
23 clang           0x00000000016105c0
24 clang           0x0000000001603c36
25 clang           0x00000000015fcdb6
26 clang           0x00000000015faf81 clang::Sema::SubstStmt(clang::Stmt*,
clang::MultiLevelTemplateArgumentList const&) + 125
27 clang           0x000000000161ed46
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool) + 1506
28 clang           0x0000000001620b49
clang::Sema::PerformPendingInstantiations(bool) + 341
29 clang           0x000000000161ee87
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool) + 1827
30 clang           0x0000000001620b49
clang::Sema::PerformPendingInstantiations(bool) + 341
31 clang           0x000000000141bc89 clang::Sema::ActOnEndOfTranslationUnit()
+ 307
32 clang           0x00000000013e0702
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 80
33 clang           0x00000000013cac00 clang::ParseAST(clang::Sema&, bool) + 328
34 clang           0x000000000114027d clang::ASTFrontendAction::ExecuteAction()
+ 263
35 clang           0x00000000012697fb clang::CodeGenAction::ExecuteAction() +
969
36 clang           0x000000000113fed0 clang::FrontendAction::Execute() + 320
37 clang           0x0000000001128aa1
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 745
38 clang           0x00000000010d8695
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 878
39 clang           0x00000000010cb48f cc1_main(char const**, char const**, char
const*, void*) + 990
40 clang           0x00000000010d47a4 main + 484
41 libc.so.6       0x00007ff79dd18cdd __libc_start_main + 253
42 clang           0x00000000010cab09
Stack dump:
0.      Program arguments: /home/bpoint/src/clang/build/Debug+Asserts/bin/clang
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name delegate.cpp -mrelocation-model static -mdisable-fp-elim
-masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64
-target-linker-version 2.20.1.20100303 -resource-dir
/home/bpoint/src/clang/build/Debug+Asserts/bin/../lib/clang/2.9 -ferror-limit
19 -fmessage-length 132 -fexceptions -fgnu-runtime -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/cc-Qfat7a.o -x c++ delegate.cpp 
1.      <eof> parser at end of file
2.      delegate.cpp:50:24: instantiating function definition 'Delegate2'
3.      delegate.cpp:13:2: instantiating function definition 'Delegate'
clang: error: unable to execute command: Aborted
clang: error: clang frontend command failed due to signal 1 (use -v to see
invocation)

The source is a C++ delegate implementation, derived from
http://www.codeproject.com/KB/cpp/CppDelegateImplementation.aspx .  I have
attached a stripped-down version of the code to this bug report.

Incidentally, clang-2.8 generates two errors on this source file without
crashing.  MSVC (VS2008), gcc-4.4, and comeau have no issues with compiling.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list