public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67050] New: [C++14] ICE when calling a template member function from a lambda with implicit "this" capture
@ 2015-07-29  7:01 ldionne.2 at gmail dot com
  2015-07-29  7:02 ` [Bug c++/67050] " ldionne.2 at gmail dot com
  2015-08-19  9:44 ` mpolacek at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: ldionne.2 at gmail dot com @ 2015-07-29  7:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67050
           Summary: [C++14] ICE when calling a template member function
                    from a lambda with implicit "this" capture
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ldionne.2 at gmail dot com
  Target Milestone: ---

Hi,

The following code triggers an ICE (segmentation fault) on GCC trunk:
---------------------------------------------------------------------
struct Foo {
    template <typename>
    void X() { }

    void test() {
        auto by_ref = [&](auto arg) {
            // anything that makes X<...> dependent will do
            X<decltype(arg)>();
        };
        by_ref(1);

        auto by_val = [=](auto arg) {
            X<decltype(arg)>();
        };
        by_val(1);
    }
};


int main() {
    Foo foo;
    foo.test();
}
---------------------------------------------------------------------


Formatted to fit the report, the error is:
---------------------------------------------------------------------
prog.cc: In lambda function:
prog.cc:8:29: internal compiler error: Segmentation fault
             X<decltype(arg)>();
                             ^
0xae69af crash_signal
    /home/heads/gcc/gcc-source/gcc/toplev.c:352
0x854887 size_binop_loc(unsigned int, tree_code, tree_node*, tree_node*)
    /home/heads/gcc/gcc-source/gcc/fold-const.c:1732
0x9308fd gimplify_compound_lval
    /home/heads/gcc/gcc-source/gcc/gimplify.c:2014
0x92bb93 gimplify_expr(tree_node**, gimple_statement_base**, 
                                    gimple_statement_base**, 
                                    bool (*)(tree_node*), int)
    /home/heads/gcc/gcc-source/gcc/gimplify.c:8021
0x9314bb gimplify_call_expr
    /home/heads/gcc/gcc-source/gcc/gimplify.c:2452
0x92d26d gimplify_expr(tree_node**, gimple_statement_base**, 
                                    gimple_statement_base**, 
                                    bool (*)(tree_node*), int)
    /home/heads/gcc/gcc-source/gcc/gimplify.c:8040
0x92ea06 gimplify_stmt(tree_node**, gimple_statement_base**)
    /home/heads/gcc/gcc-source/gcc/gimplify.c:5525
0x92cf5d gimplify_cleanup_point_expr
    /home/heads/gcc/gcc-source/gcc/gimplify.c:5301
0x92cf5d gimplify_expr(tree_node**, gimple_statement_base**, 
                                    gimple_statement_base**, 
                                    bool (*)(tree_node*), int)
    /home/heads/gcc/gcc-source/gcc/gimplify.c:8432
0x92ea06 gimplify_stmt(tree_node**, gimple_statement_base**)
    /home/heads/gcc/gcc-source/gcc/gimplify.c:5525
0x92f7af gimplify_bind_expr
    /home/heads/gcc/gcc-source/gcc/gimplify.c:1111
0x92d24c gimplify_expr(tree_node**, gimple_statement_base**, 
                                    gimple_statement_base**, 
                                    bool (*)(tree_node*), int)
    /home/heads/gcc/gcc-source/gcc/gimplify.c:8266
0x92ea06 gimplify_stmt(tree_node**, gimple_statement_base**)
    /home/heads/gcc/gcc-source/gcc/gimplify.c:5525
0x93491e gimplify_body(tree_node*, bool)
    /home/heads/gcc/gcc-source/gcc/gimplify.c:9203
0x934c47 gimplify_function_tree(tree_node*)
    /home/heads/gcc/gcc-source/gcc/gimplify.c:9361
0x782da7 cgraph_node::analyze()
    /home/heads/gcc/gcc-source/gcc/cgraphunit.c:636
0x785447 analyze_functions
    /home/heads/gcc/gcc-source/gcc/cgraphunit.c:1028
0x785cf0 symbol_table::finalize_compilation_unit()
    /home/heads/gcc/gcc-source/gcc/cgraphunit.c:2477
------------------------------------------------------------------------------

Live example: http://melpon.org/wandbox/permlink/eN6sRg5AacE50CrZ
Note that Clang compiles this code just fine.

Curiously enough, using any of the following lambdas will 
not trigger the ICE:

(1)
    [this](auto arg) {
        X<decltype(arg)>();
    };

(2)
    [this](auto arg) {
        this->X<decltype(arg)>();
    };

(3)
    [=](auto arg) {
        this->X<decltype(arg)>();
    };

(4)
    [&](auto arg) {
        this->X<decltype(arg)>();
    };

I will also attach a test case checking for all of the above patterns.
You might want to add this to GCC's unit tests.


Related to 53741 and 54604
Maybe a duplicate of 61636


Regards,
Louis Dionne


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

* [Bug c++/67050] [C++14] ICE when calling a template member function from a lambda with implicit "this" capture
  2015-07-29  7:01 [Bug c++/67050] New: [C++14] ICE when calling a template member function from a lambda with implicit "this" capture ldionne.2 at gmail dot com
@ 2015-07-29  7:02 ` ldionne.2 at gmail dot com
  2015-08-19  9:44 ` mpolacek at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: ldionne.2 at gmail dot com @ 2015-07-29  7:02 UTC (permalink / raw)
  To: gcc-bugs

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

Louis Dionne <ldionne.2 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ldionne.2 at gmail dot com

--- Comment #1 from Louis Dionne <ldionne.2 at gmail dot com> ---
Created attachment 36084
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36084&action=edit
Test case

Promised test case


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

* [Bug c++/67050] [C++14] ICE when calling a template member function from a lambda with implicit "this" capture
  2015-07-29  7:01 [Bug c++/67050] New: [C++14] ICE when calling a template member function from a lambda with implicit "this" capture ldionne.2 at gmail dot com
  2015-07-29  7:02 ` [Bug c++/67050] " ldionne.2 at gmail dot com
@ 2015-08-19  9:44 ` mpolacek at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-08-19  9:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(But it's a different ICE than the one in the Description.)


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

end of thread, other threads:[~2015-08-19  9:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-29  7:01 [Bug c++/67050] New: [C++14] ICE when calling a template member function from a lambda with implicit "this" capture ldionne.2 at gmail dot com
2015-07-29  7:02 ` [Bug c++/67050] " ldionne.2 at gmail dot com
2015-08-19  9:44 ` mpolacek at gcc dot gnu.org

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).