https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80267
Bug ID: 80267
Summary: Compiling aborts when template/auto/lambda occur in
some way
Product: gcc
Version: 7.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: s-beyer at gmx dot net
Target Milestone: ---
Hi,
g++ 7.0.1 asks me for reporting a bug, so I do it.
I have the following minimal example:
$ cat gcc-bug.cpp
#include <functional>
struct Outer {
struct Inner {
void func();
};
const Inner &inner() const;
Inner &inner();
};
void run(std::function<void()> func) { func(); }
template<typename T> void test() {
Outer ocm;
auto &inner = ocm.inner();
run([&]() {
inner.func();
run([&]() { inner.func(); });
});
}
int main() { test<bool>(); };
And the following happens with g++ 7.0.1
$ g++-7 --version
g++-7 (Debian 7-20170302-1) 7.0.1 20170302 (experimental) [trunk revision
245832]
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++-7 -c gcc-bug.cpp && echo GOOD
gcc-bug.cpp: In instantiation of ‘test()::<lambda()>::<lambda()> [with T =
bool]’:
gcc-bug.cpp:20:11: required from ‘struct test()::<lambda()> [with T =
bool]::<lambda()>’
gcc-bug.cpp:20:8: required from ‘test()::<lambda()> [with T = bool]’
gcc-bug.cpp:18:9: required from ‘struct test() [with T = bool]::<lambda()>’
gcc-bug.cpp:18:6: required from ‘void test() [with T = bool]’
gcc-bug.cpp:24:25: required from here
gcc-bug.cpp:20:17: internal compiler error: in tsubst_copy, at cp/pt.c:14589
run([&]() { inner.func(); });
^~~~~
0x5e9c2c tsubst_copy
../../src/gcc/cp/pt.c:14587
0x5ed9fe tsubst_copy
../../src/gcc/cp/pt.c:14414
0x5ed9fe tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../src/gcc/cp/pt.c:17727
0x5ed868 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../src/gcc/cp/pt.c:16665
0x5ed8e1 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../src/gcc/cp/pt.c:17507
0x5ed49e tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../src/gcc/cp/pt.c:17128
0x5e6a27 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:16446
0x5e5485 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15711
0x5e6853 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15923
0x5e6853 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15923
0x5e4ef6 instantiate_decl(tree_node*, bool, bool)
../../src/gcc/cp/pt.c:22874
0x5fcfcd instantiate_class_template_1
../../src/gcc/cp/pt.c:10716
0x5fcfcd instantiate_class_template(tree_node*)
../../src/gcc/cp/pt.c:10786
0x65f9d5 complete_type(tree_node*)
../../src/gcc/cp/typeck.c:133
0x5ecaa9 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../src/gcc/cp/pt.c:17859
0x5ee406 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../src/gcc/cp/pt.c:17144
0x5e6a27 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:16446
0x5e5485 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15711
0x5e6605 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15697
0x5e6853 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15923
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
Whereas g++ 6.3 works:
$ g++ --version
g++ (Debian 6.3.0-8) 6.3.0 20170221
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++ -c gcc-bug.cpp && echo GOOD
GOOD
Best
Stephan