This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/58761] New: ICE with a lambda capturing this in a NSDMI
- From: "ville.voutilainen at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 16 Oct 2013 22:54:11 +0000
- Subject: [Bug c++/58761] New: ICE with a lambda capturing this in a NSDMI
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58761
Bug ID: 58761
Summary: ICE with a lambda capturing this in a NSDMI
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ville.voutilainen at gmail dot com
An unreduced (sorry) test snippet:
#include <forward_list>
#include <utility>
#include <iostream>
template <class T>
struct two_sided_list : std::forward_list<T>
{
using std::forward_list<T>::forward_list;
typename std::forward_list<T>::iterator push_back(T&& t)
{
end_ = this->insert_after(end_, std::forward<T>(t));
}
T& back()
{
return *end_;
}
private:
typename std::forward_list<T>::iterator end_ = [this](){this->end();}(); //
#1
};
int main()
{
two_sided_list<int> tsl{1,2,3};
std::cout << "back is " << tsl.back() << std::endl;
tsl.push_back(4);
std::cout << "back is " << tsl.back() << std::endl;
}
Goes kaboom:
twosided_fwdlist_bug.cpp: In instantiation of âstruct
two_sided_list<int>::<lambda()>â:
twosided_fwdlist_bug.cpp:18:73: required from here
twosided_fwdlist_bug.cpp:18:51: internal compiler error: in tsubst_copy, at
cp/pt.c:12344
typename std::forward_list<T>::iterator end_ = [this](){this->end();}();
^
0x5ab2e8 tsubst_copy
../../gcc/cp/pt.c:12344
0x585cab tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../gcc/cp/pt.c:14921
0x5873bb tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../gcc/cp/pt.c:13987
0x585e15 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../gcc/cp/pt.c:14693
0x5c8ada instantiate_class_template_1
../../gcc/cp/pt.c:9181
0x5c8ada instantiate_class_template(tree_node*)
../../gcc/cp/pt.c:9239
0x659f7b complete_type(tree_node*)
../../gcc/cp/typeck.c:132
0x586c75 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../gcc/cp/pt.c:15018
0x5876c7 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../gcc/cp/pt.c:14415
0x68a0e6 perform_member_init
../../gcc/cp/init.c:538
0x68a0e6 emit_mem_initializers(tree_node*)
../../gcc/cp/init.c:1096
0x695172 do_build_copy_constructor
../../gcc/cp/method.c:622
0x695172 synthesize_method(tree_node*)
../../gcc/cp/method.c:794
0x605be9 mark_used(tree_node*, int)
../../gcc/cp/decl2.c:4778
0x534926 build_over_call
../../gcc/cp/call.c:7116
0x53071e build_new_method_call_1
../../gcc/cp/call.c:7813
0x53071e build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
../../gcc/cp/call.c:7883
0x531692 build_special_member_call(tree_node*, tree_node*, vec<tree_node*,
va_gc, vl_embed>**, tree_node*, int, int)
../../gcc/cp/call.c:7440
0x686417 expand_default_init
../../gcc/cp/init.c:1668
0x686417 expand_aggr_init_1
../../gcc/cp/init.c:1769
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
If #1 is
typename std::forward_list<T>::iterator end_ = this->end();
then it doesn't barf. That doesn't work, though, but that's not the compiler's
fault. If #1 is
typename std::forward_list<T>::iterator end_ = [](typename
std::forward_list<T>::iterator s, typename std::forward_list<T>::iterator
e){auto r = s; while (++s != e) r = s; return r;}(this->begin(), this->end());
it compiles and runs correctly.
I'll try to create a bit more reduced test snippet soon.