[LLVMbugs] [Bug 23836] New: Clang crash when using std::unordered_map with std::array and empty initialization

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jun 12 14:03:30 PDT 2015


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

            Bug ID: 23836
           Summary: Clang crash when using std::unordered_map with
                    std::array and empty initialization
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rtrieu at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Reduced test case:
#include <array>
#include <unordered_map>

void foo() {
  std::array<std::unordered_map<int, int>, 5> v = {}; 
}

Command:
clang b.cpp -std=c++11

Reduced test case without includes:
# 1 "unordered_map" 1 3
namespace std {

template<typename _Tp, int _Nm>
struct __array_traits {
  typedef _Tp _Type[_Nm];
};

template<typename _Tp, int _Nm>
struct array {
  typedef std::__array_traits<_Tp, _Nm> _AT_Type;
  typename _AT_Type::_Type              _M_elems;
};

template<class _Key, class _Tp>
class unordered_map {
  explicit unordered_map() { }

};

} // namespace std

# 1 "foo.cc" 1

void Foo() {
  std::array<std::unordered_map<int,int>, 5> v = {};
}

Command:
clang -cc1 -std=c++11 c.cpp

lib/Sema/SemaInit.cpp:
 443            if (!VerifyOnly) {
 444              SemaRef.Diag(CtorDecl->getLocation(),
 445                          
diag::warn_invalid_initializer_from_system_header);
>446	          SemaRef.Diag(Entity.getDecl()->getLocation(),
 447                           diag::note_used_in_initialization_here);
 448            }
On line 446, Entity.getDecl() returns a null pointer, leading to a null
dereference in getLocation()

Backtrace:
#0 0x16003aa llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/bin/clang-3.5+0x16003aa)
#1 0x160173b SignalHandler(int) (/usr/local/bin/clang-3.5+0x160173b)
#2 0x7f0eb742c340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#3 0x2448132 (anonymous
namespace)::InitListChecker::PerformEmptyInit(clang::Sema&,
clang::SourceLocation, clang::InitializedEntity const&, bool)
(/usr/local/bin/clang-3.5+0x2448132)
#4 0x2441ccb (anonymous
namespace)::InitListChecker::FillInEmptyInitializations(clang::InitializedEntity
const&, clang::InitListExpr*, bool&, bool) (/usr/local/bin/clang-3.5+0x2441ccb)
#5 0x2439646 (anonymous
namespace)::InitListChecker::InitListChecker(clang::Sema&,
clang::InitializedEntity const&, clang::InitListExpr*, clang::QualType&, bool)
(/usr/local/bin/clang-3.5+0x2439646)
#6 0x2430556 clang::InitializationSequence::Perform(clang::Sema&,
clang::InitializedEntity const&, clang::InitializationKind const&,
llvm::MutableArrayRef<clang::Expr*>, clang::QualType*)
(/usr/local/bin/clang-3.5+0x2430556)
#7 0x24481e0 (anonymous
namespace)::InitListChecker::PerformEmptyInit(clang::Sema&,
clang::SourceLocation, clang::InitializedEntity const&, bool)
(/usr/local/bin/clang-3.5+0x24481e0)
#8 0x244d0f3 (anonymous
namespace)::InitListChecker::FillInEmptyInitForField(unsigned int,
clang::FieldDecl*, clang::InitializedEntity const&, clang::InitListExpr*,
bool&, bool) (/usr/local/bin/clang-3.5+0x244d0f3)
#9 0x2441fdb (anonymous
namespace)::InitListChecker::FillInEmptyInitializations(clang::InitializedEntity
const&, clang::InitListExpr*, bool&, bool) (/usr/local/bin/clang-3.5+0x2441fdb)
#10 0x2439646 (anonymous
namespace)::InitListChecker::InitListChecker(clang::Sema&,
clang::InitializedEntity const&, clang::InitListExpr*, clang::QualType&, bool)
(/usr/local/bin/clang-3.5+0x2439646)
#11 0x2430556 clang::InitializationSequence::Perform(clang::Sema&,
clang::InitializedEntity const&, clang::InitializationKind const&,
llvm::MutableArrayRef<clang::Expr*>, clang::QualType*)
(/usr/local/bin/clang-3.5+0x2430556)
#12 0x2260936 clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*,
bool, bool) (/usr/local/bin/clang-3.5+0x2260936)
#13 0x1ff0524
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/usr/local/bin/clang-3.5+0x1ff0524)
#14 0x1fee198 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned
int, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/local/bin/clang-3.5+0x1fee198)
#15 0x1fe9df7 clang::Parser::ParseSimpleDeclaration(unsigned int,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&, bool,
clang::Parser::ForRangeInit*) (/usr/local/bin/clang-3.5+0x1fe9df7)
#16 0x1fe9a3a clang::Parser::ParseDeclaration(unsigned int,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&)
(/usr/local/bin/clang-3.5+0x1fe9a3a)
#17 0x20539bd
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&)
(/usr/local/bin/clang-3.5+0x20539bd)
#18 0x2053651
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*) (/usr/local/bin/clang-3.5+0x2053651)
#19 0x205ac6f clang::Parser::ParseCompoundStatementBody(bool)
(/usr/local/bin/clang-3.5+0x205ac6f)
#20 0x205b4b3 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) (/usr/local/bin/clang-3.5+0x205b4b3)
#21 0x1fdc980 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/usr/local/bin/clang-3.5+0x1fdc980)
#22 0x1fee09f clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned
int, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/local/bin/clang-3.5+0x1fee09f)
#23 0x1fdbfed
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/usr/local/bin/clang-3.5+0x1fdbfed)
#24 0x1fdba3c
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/usr/local/bin/clang-3.5+0x1fdba3c)
#25 0x1fdab6b
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/local/bin/clang-3.5+0x1fdab6b)
#26 0x1fda09b
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/local/bin/clang-3.5+0x1fda09b)
#27 0x1fd60b6 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/bin/clang-3.5+0x1fd60b6)
#28 0x17ac19e clang::FrontendAction::Execute()
(/usr/local/bin/clang-3.5+0x17ac19e)
#29 0x177b86c clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/bin/clang-3.5+0x177b86c)
#30 0x18292e8 clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/bin/clang-3.5+0x18292e8)
#31 0x7040ec cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
(/usr/local/bin/clang-3.5+0x7040ec)
#32 0x702f70 main (/usr/local/bin/clang-3.5+0x702f70)
#33 0x7f0eb6943ec5 __libc_start_main
/build/buildd/eglibc-2.19/csu/libc-start.c:321:0
#34 0x70014c _start (/usr/local/bin/clang-3.5+0x70014c)

-- 
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/20150612/be89b6b7/attachment.html>


More information about the llvm-bugs mailing list