<html>
    <head>
      <base href="http://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 --- - Crashes building lld"
   href="http://llvm.org/bugs/show_bug.cgi?id=17476">17476</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Crashes building lld
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>rafael.espindola@gmail.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 testcase:

struct string {
  string(const char *__s);
  string &operator+=(const string &__str);
};

template <class ELFT> void finalizeDefaultAtomValues() {
  auto startEnd = [&](const char * sym)->void {
    string start("__");
    start += sym;
  }
  ;
  startEnd("preinit_array");
}

void f() { finalizeDefaultAtomValues<int>(); }


$ clang -cc1 -std=c++11 Writer.ii -emit-llvm
clang: /home/espindola/llvm/llvm/tools/clang/lib/CodeGen/CGExpr.cpp:1784:
clang::CodeGen::LValue clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(const
clang::DeclRefExpr*): Assertion `isa<BlockDecl>(CurCodeDecl) &&
E->refersToEnclosingLocal()' failed.
0  clang           0x0000000001da88f4 llvm::sys::PrintStackTrace(_IO_FILE*) +
38
1  clang           0x0000000001da8b71
2  clang           0x0000000001da852e
3  libpthread.so.0 0x00000032ef80efa0
4  libc.so.6       0x00000032ef435a19 gsignal + 57
5  libc.so.6       0x00000032ef437128 abort + 328
6  libc.so.6       0x00000032ef42e986
7  libc.so.6       0x00000032ef42ea32
8  clang           0x0000000001f3c215
clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*) +
1433
9  clang           0x0000000001f37345
clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) + 481
10 clang           0x0000000001f37054
clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*,
clang::CodeGen::CodeGenFunction::TypeCheckKind) + 278</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>