<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 --- - Assertion `isa&lt;LabelDecl&gt;(D) &amp;&amp; &quot;declaration not instantiated in this scope&quot;' failed -- in instantiation of struct inside lambda inside template struct" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23853&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=S5uMrUA5DlD_OB0VqEfIPnwttRfJBmC5lRLGfNYbPSU&s=gfw0lUEkqGxnVuH8O79w0cXs-9xPJvstLA4UZFGsvb8&e=">23853</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Assertion `isa<LabelDecl>(D) && "declaration not instantiated in this scope"' failed -- in instantiation of struct inside lambda inside template struct
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.6
          </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>C++11
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>andrey.vul@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>We have a template class containing a lambda which itself contains an inner
class.
Both inner structures -- the lambda and its inner class -- depdend on the
template parameter of the outer class.
Instantiation of this gives the assertion failure in the summary.

### SOURCE: cat t.cc
template <class R> struct S {
    S(R x1) {
        [] (R x2) -> void {
            struct A {
                R x3;
                A(R x4) : x3(x4) {}
            };
            A a(x2);
        }(x1);
    }
};
S<int> t (0);

int main() { } 

## INVOCATION: clang++ -v -std=c++11 -c t.cc
clang version 3.6.1 (tags/RELEASE_361/final)
Target: powerpc64le-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/powerpc64le-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/powerpc64le-linux-gnu/4.9.1
Selected GCC installation: /usr/lib/gcc/powerpc64le-linux-gnu/4.9
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/gsa/tlbgsa-h1/09/andreyv/clang/bin/clang-3.6" -cc1 -triple
powerpc64le-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name t.cc -mrelocation-model static -mthread-model posix
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-fuse-init-array -target-cpu ppc64le -target-abi elfv2 -v -dwarf-column-info
-coverage-file /tmp/t.cc -resource-dir
/gsa/tlbgsa-h1/09/andreyv/clang/bin/../lib/clang/3.6.1 -internal-isystem
/usr/lib/gcc/powerpc64le-linux-gnu/4.9/../../../../include/c++/4.9
-internal-isystem
/usr/lib/gcc/powerpc64le-linux-gnu/4.9/../../../../include/powerpc64le-linux-gnu/c++/4.9
-internal-isystem
/usr/lib/gcc/powerpc64le-linux-gnu/4.9/../../../../include/powerpc64le-linux-gnu/c++/4.9
-internal-isystem
/usr/lib/gcc/powerpc64le-linux-gnu/4.9/../../../../include/c++/4.9/backward
-internal-isystem /usr/local/include -internal-isystem
/gsa/tlbgsa-h1/09/andreyv/clang/bin/../lib/clang/3.6.1/include
-internal-externc-isystem /usr/include/powerpc64le-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-std=c++11 -fdeprecated-macro -fdebug-compilation-dir /tmp -ferror-limit 19
-fmessage-length 135 -mstackrealign -fno-signed-char -fobjc-runtime=gcc
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o
t.o -x c++ t.cc
clang -cc1 version 3.6.1 based upon LLVM 3.6.1 default target
powerpc64le-unknown-linux-gnu
ignoring nonexistent directory "/include"
ignoring duplicate directory
"/usr/lib/gcc/powerpc64le-linux-gnu/4.9/../../../../include/powerpc64le-linux-gnu/c++/4.9"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/powerpc64le-linux-gnu/4.9/../../../../include/c++/4.9

/usr/lib/gcc/powerpc64le-linux-gnu/4.9/../../../../include/powerpc64le-linux-gnu/c++/4.9
 /usr/lib/gcc/powerpc64le-linux-gnu/4.9/../../../../include/c++/4.9/backward
 /usr/local/include
 /gsa/tlbgsa-h1/09/andreyv/clang/bin/../lib/clang/3.6.1/include
 /usr/include/powerpc64le-linux-gnu
 /usr/include
End of search list.
clang-3.6:
/scratch/andreyv/llvm-3.6.1.src/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp:2818:
llvm::PointerUnion<clang::Decl*, llvm::SmallVector<clang::Decl*, 4u>*>*
clang::LocalInstantiationScope::findInstantiationOf(const clang::Decl*):
Assertion `isa<LabelDecl>(D) && "declaration not instantiated in this scope"'
failed.
#0 0x12703d14 llvm::sys::PrintStackTrace(_IO_FILE*)
/scratch/andreyv/llvm-3.6.1.src/lib/Support/Unix/Signals.inc:423:0
#1 0x12704090 PrintStackTraceSignalHandler(void*)
/scratch/andreyv/llvm-3.6.1.src/lib/Support/Unix/Signals.inc:480:0
#2 0x127027b0 SignalHandler(int)
/scratch/andreyv/llvm-3.6.1.src/lib/Support/Unix/Signals.inc:199:0
0  clang-3.6 0x0000000012703d14 llvm::sys::PrintStackTrace(_IO_FILE*) + 68
1  clang-3.6 0x0000000012704090
2  clang-3.6 0x00000000127027b0
3            0x00003fffa5a80478 __kernel_sigtramp_rt64 + 0
4  libc.so.6 0x00003fffa55d06b8 gsignal + 72
5  libc.so.6 0x00003fffa55d295c abort + 636
6  libc.so.6 0x00003fffa55c6274
7  libc.so.6 0x00003fffa55c6364 __assert_fail + 100
8  clang-3.6 0x000000001475abc4
clang::LocalInstantiationScope::findInstantiationOf(clang::Decl const*) + 500
9  clang-3.6 0x00000000147ae6d4
clang::Sema::FindInstantiatedDecl(clang::SourceLocation, clang::NamedDecl*,
clang::MultiLevelTemplateArgumentList const&) + 492
10 clang-3.6 0x00000000147ae4a8
clang::Sema::FindInstantiatedContext(clang::SourceLocation,
clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) + 88
11 clang-3.6 0x00000000147aec20
clang::Sema::FindInstantiatedDecl(clang::SourceLocation, clang::NamedDecl*,
clang::MultiLevelTemplateArgumentList const&) + 1848
12 clang-3.6 0x00000000147ad578
clang::Sema::InstantiateMemInitializers(clang::CXXConstructorDecl*,
clang::CXXConstructorDecl const*, clang::MultiLevelTemplateArgumentList const&)
+ 1676
13 clang-3.6 0x00000000147aadf8
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool) + 2536
14 clang-3.6 0x00000000147af394 clang::Sema::PerformPendingInstantiations(bool)
+ 364
15 clang-3.6 0x00000000147aafa4
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool) + 2964
16 clang-3.6 0x00000000147af394 clang::Sema::PerformPendingInstantiations(bool)
+ 364
17 clang-3.6 0x0000000014078e80 clang::Sema::ActOnEndOfTranslationUnit() + 788
18 clang-3.6 0x0000000013da174c
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 548
19 clang-3.6 0x0000000013d96a8c clang::ParseAST(clang::Sema&, bool, bool) + 692
20 clang-3.6 0x00000000129d96f0 clang::ASTFrontendAction::ExecuteAction() + 468
21 clang-3.6 0x0000000012e95858 clang::CodeGenAction::ExecuteAction() + 1388
22 clang-3.6 0x00000000129d8ff8 clang::FrontendAction::Execute() + 188
23 clang-3.6 0x0000000012986600
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1044
24 clang-3.6 0x0000000012ba8b5c
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1316
25 clang-3.6 0x0000000010db9038 cc1_main(llvm::ArrayRef<char const*>, char
const*, void*) + 876
26 clang-3.6 0x0000000010daac88
27 clang-3.6 0x0000000010dab3d4 main + 1040
28 libc.so.6 0x00003fffa55b4e80
29 libc.so.6 0x00003fffa55b5074 __libc_start_main + 196
Stack dump:
0.    Program arguments: /gsa/tlbgsa-h1/09/andreyv/clang/bin/clang-3.6 -cc1
-triple powerpc64le-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name t.cc -mrelocation-model static -mthread-model posix
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-fuse-init-array -target-cpu ppc64le -target-abi elfv2 -v -dwarf-column-info
-coverage-file /tmp/t.cc -resource-dir
/gsa/tlbgsa-h1/09/andreyv/clang/bin/../lib/clang/3.6.1 -internal-isystem
/usr/lib/gcc/powerpc64le-linux-gnu/4.9/../../../../include/c++/4.9
-internal-isystem
/usr/lib/gcc/powerpc64le-linux-gnu/4.9/../../../../include/powerpc64le-linux-gnu/c++/4.9
-internal-isystem
/usr/lib/gcc/powerpc64le-linux-gnu/4.9/../../../../include/powerpc64le-linux-gnu/c++/4.9
-internal-isystem
/usr/lib/gcc/powerpc64le-linux-gnu/4.9/../../../../include/c++/4.9/backward
-internal-isystem /usr/local/include -internal-isystem
/gsa/tlbgsa-h1/09/andreyv/clang/bin/../lib/clang/3.6.1/include
-internal-externc-isystem /usr/include/powerpc64le-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-std=c++11 -fdeprecated-macro -fdebug-compilation-dir /tmp -ferror-limit 19
-fmessage-length 135 -mstackrealign -fno-signed-char -fobjc-runtime=gcc
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o
t.o -x c++ t.cc 
1.    <eof> parser at end of file
2.    t.cc:2:2: instantiating function definition 'S'
3.    t.cc:6:5: instantiating function definition 'A'
clang-3.6: error: unable to execute command: Aborted
clang-3.6: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.6.1 (tags/RELEASE_361/final)
Target: powerpc64le-unknown-linux-gnu
Thread model: posix
clang-3.6: note: diagnostic msg: PLEASE submit a bug report to
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_bugs_&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=S5uMrUA5DlD_OB0VqEfIPnwttRfJBmC5lRLGfNYbPSU&s=gZTXuirEWqTy2yQivNVNkkD2blYOJ6NeMQgocCE83Xc&e=">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and
associated run script.
clang-3.6: note: diagnostic msg: 
********************</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>