public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58761] New: ICE with a lambda capturing this in a NSDMI
@ 2013-10-16 22:54 ville.voutilainen at gmail dot com
  2013-10-21  9:51 ` [Bug c++/58761] " paolo.carlini at oracle dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: ville.voutilainen at gmail dot com @ 2013-10-16 22:54 UTC (permalink / raw)
  To: gcc-bugs

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.
>From gcc-bugs-return-432016-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Oct 16 22:54:05 2013
Return-Path: <gcc-bugs-return-432016-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 26329 invoked by alias); 16 Oct 2013 22:54:05 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 26298 invoked by uid 48); 16 Oct 2013 22:54:02 -0000
From: "paolo.carlini at oracle dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/57887] nested non-type template parameters not declared in this scope
Date: Wed, 16 Oct 2013 22:54:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.8.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: paolo.carlini at oracle dot com
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on everconfirmed
Message-ID: <bug-57887-4-TIunOUKa6D@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-57887-4@http.gcc.gnu.org/bugzilla/>
References: <bug-57887-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-10/txt/msg01160.txt.bz2
Content-length: 490

http://gcc.gnu.org/bugzilla/show_bug.cgi?idW887

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-10-16
     Ever confirmed|0                           |1

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Confirmed.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/58761] ICE with a lambda capturing this in a NSDMI
  2013-10-16 22:54 [Bug c++/58761] New: ICE with a lambda capturing this in a NSDMI ville.voutilainen at gmail dot com
@ 2013-10-21  9:51 ` paolo.carlini at oracle dot com
  2013-10-21 17:40 ` ville.voutilainen at gmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-21  9:51 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58761

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-10-21
                 CC|paolo.carlini at oracle dot com    |
     Ever confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Almost certainly Dup of PR58824 (which has a more reduced testcase)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/58761] ICE with a lambda capturing this in a NSDMI
  2013-10-16 22:54 [Bug c++/58761] New: ICE with a lambda capturing this in a NSDMI ville.voutilainen at gmail dot com
  2013-10-21  9:51 ` [Bug c++/58761] " paolo.carlini at oracle dot com
@ 2013-10-21 17:40 ` ville.voutilainen at gmail dot com
  2013-11-18 17:12 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ville.voutilainen at gmail dot com @ 2013-10-21 17:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58761

--- Comment #2 from Ville Voutilainen <ville.voutilainen at gmail dot com> ---
Reduced:

template <class T>
struct X
{
  int x = 42;
  int y = [this](){return this->x;}();
};

int main()
{
  X<int> x;
}


Seems to require a template to trigger, but from that point onwards,
it's quite easy to trigger. Including the trace just in case it's
somehow different:

twosided_reduced.cpp: In instantiation of ‘struct X<int>::<lambda()>’:
twosided_reduced.cpp:5:37:   required from here
twosided_reduced.cpp:5:12: internal compiler error: in tsubst_copy, at
cp/pt.c:12344
   int y = [this](){return this->x;}();
            ^
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
0x69481e synthesize_method(tree_node*)
    ../../gcc/cp/method.c:796
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
0x688fe9 build_aggr_init(tree_node*, tree_node*, int, int)
    ../../gcc/cp/init.c:1520
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.
>From gcc-bugs-return-432383-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Oct 21 17:59:42 2013
Return-Path: <gcc-bugs-return-432383-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 31173 invoked by alias); 21 Oct 2013 17:59:42 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 31137 invoked by uid 48); 21 Oct 2013 17:59:39 -0000
From: "paolo.carlini at oracle dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/58761] ICE with a lambda capturing this in a NSDMI
Date: Mon, 21 Oct 2013 17:59:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: paolo.carlini at oracle dot com
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-58761-4-eCbdRfm7ZJ@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58761-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58761-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-10/txt/msg01527.txt.bz2
Content-length: 173

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX761

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Thanks Ville. Now we are only missing a patch ;)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/58761] ICE with a lambda capturing this in a NSDMI
  2013-10-16 22:54 [Bug c++/58761] New: ICE with a lambda capturing this in a NSDMI ville.voutilainen at gmail dot com
  2013-10-21  9:51 ` [Bug c++/58761] " paolo.carlini at oracle dot com
  2013-10-21 17:40 ` ville.voutilainen at gmail dot com
@ 2013-11-18 17:12 ` paolo.carlini at oracle dot com
  2014-05-19 18:42 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-11-18 17:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58761

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thomas.sanchz at gmail dot com

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> ---
*** Bug 58824 has been marked as a duplicate of this bug. ***


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/58761] ICE with a lambda capturing this in a NSDMI
  2013-10-16 22:54 [Bug c++/58761] New: ICE with a lambda capturing this in a NSDMI ville.voutilainen at gmail dot com
                   ` (2 preceding siblings ...)
  2013-11-18 17:12 ` paolo.carlini at oracle dot com
@ 2014-05-19 18:42 ` jason at gcc dot gnu.org
  2014-05-20 20:25 ` jason at gcc dot gnu.org
  2015-01-08 17:33 ` paolo.carlini at oracle dot com
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2014-05-19 18:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58761

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Mon May 19 18:41:24 2014
New Revision: 210624

URL: http://gcc.gnu.org/viewcvs?rev=210624&root=gcc&view=rev
Log:
    PR c++/58761
    * pt.c (tsubst_copy): Don't check at_function_scope_p.
    (instantiate_class_template_1): Don't push_to_top_level in an nsdmi.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi6.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/58761] ICE with a lambda capturing this in a NSDMI
  2013-10-16 22:54 [Bug c++/58761] New: ICE with a lambda capturing this in a NSDMI ville.voutilainen at gmail dot com
                   ` (3 preceding siblings ...)
  2014-05-19 18:42 ` jason at gcc dot gnu.org
@ 2014-05-20 20:25 ` jason at gcc dot gnu.org
  2015-01-08 17:33 ` paolo.carlini at oracle dot com
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2014-05-20 20:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58761

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |jason at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
   Target Milestone|---                         |4.10.0

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed on trunk so far.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/58761] ICE with a lambda capturing this in a NSDMI
  2013-10-16 22:54 [Bug c++/58761] New: ICE with a lambda capturing this in a NSDMI ville.voutilainen at gmail dot com
                   ` (4 preceding siblings ...)
  2014-05-20 20:25 ` jason at gcc dot gnu.org
@ 2015-01-08 17:33 ` paolo.carlini at oracle dot com
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-01-08 17:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58761

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> ---
I think we can close this.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-01-08 17:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-16 22:54 [Bug c++/58761] New: ICE with a lambda capturing this in a NSDMI ville.voutilainen at gmail dot com
2013-10-21  9:51 ` [Bug c++/58761] " paolo.carlini at oracle dot com
2013-10-21 17:40 ` ville.voutilainen at gmail dot com
2013-11-18 17:12 ` paolo.carlini at oracle dot com
2014-05-19 18:42 ` jason at gcc dot gnu.org
2014-05-20 20:25 ` jason at gcc dot gnu.org
2015-01-08 17:33 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).