<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW " title="NEW --- - Clang crash when using std::unordered_map with std::array and empty initialization" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23836&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=LJkrFwc709yQ67QhvBfg9Mc8hxqJgz6ocXjahuquy-Y&s=9spuwQepKgd48NFqcrmqCh4_tyIbzHQovBJsHR-buL0&e=">23836</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang crash when using std::unordered_map with std::array and empty initialization
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>rtrieu@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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);
<span class="quote">>446               SemaRef.Diag(Entity.getDecl()->getLocation(),</span >
 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)</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>