public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58597] New: [c++11] ICE with lambda in default argument of template function
@ 2013-10-02 20:25 reichelt at gcc dot gnu.org
  2013-10-03 10:36 ` [Bug c++/58597] " mpolacek at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: reichelt at gcc dot gnu.org @ 2013-10-02 20:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58597
           Summary: [c++11] ICE with lambda in default argument of
                    template function
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: reichelt at gcc dot gnu.org

The following valid code snippet (compiled with "-std=c++11") triggers an ICE
since GCC 4.5.0 (when lambdas were introduced):

===============================================================
template<typename> struct A
{
  template<typename T> A(T, int = []{ return 0; }()) {}
};

A<int> a = 0;
===============================================================

bug.cc: In substitution of 'template<class T> A< <template-parameter-1-1>
>::A(T, int) [with T = int]':
bug.cc:6:12:   required from here
bug.cc:6:12: internal compiler error: in instantiate_template_1, at
cp/pt.c:15008
 A<int> a = 0;
            ^
0x5d0b93 instantiate_template_1
        ../../gcc/gcc/cp/pt.c:15008
0x5d0b93 instantiate_template(tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/pt.c:15117
0x5d264a fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, bool, bool)
        ../../gcc/gcc/cp/pt.c:15466
0x53f0fc add_template_candidate_real
        ../../gcc/gcc/cp/call.c:2923
0x53ae69 add_template_candidate
        ../../gcc/gcc/cp/call.c:3020
0x53ae69 add_candidates
        ../../gcc/gcc/cp/call.c:5075
0x53bd40 build_user_type_conversion_1
        ../../gcc/gcc/cp/call.c:3484
0x546013 build_user_type_conversion(tree_node*, tree_node*, int, int)
        ../../gcc/gcc/cp/call.c:3653
0x6843da ocp_convert(tree_node*, tree_node*, int, int, int)
        ../../gcc/gcc/cp/cvt.c:865
0x6913dd expand_default_init
        ../../gcc/gcc/cp/init.c:1597
0x6913dd expand_aggr_init_1
        ../../gcc/gcc/cp/init.c:1766
0x693b79 build_aggr_init(tree_node*, tree_node*, int, int)
        ../../gcc/gcc/cp/init.c:1517
0x557da5 build_aggr_init_full_exprs
        ../../gcc/gcc/cp/decl.c:5543
0x557da5 check_initializer
        ../../gcc/gcc/cp/decl.c:5678
0x56aa5c cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ../../gcc/gcc/cp/decl.c:6347
0x65196f cp_parser_init_declarator
        ../../gcc/gcc/cp/parser.c:16567
0x65207f cp_parser_simple_declaration
        ../../gcc/gcc/cp/parser.c:10986
0x653ee0 cp_parser_block_declaration
        ../../gcc/gcc/cp/parser.c:10867
0x65cf1e cp_parser_declaration
        ../../gcc/gcc/cp/parser.c:10764
0x65bc8a cp_parser_declaration_seq_opt
        ../../gcc/gcc/cp/parser.c:10650
Please submit a full bug report, [etc.]


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

* [Bug c++/58597] [c++11] ICE with lambda in default argument of template function
  2013-10-02 20:25 [Bug c++/58597] New: [c++11] ICE with lambda in default argument of template function reichelt at gcc dot gnu.org
@ 2013-10-03 10:36 ` mpolacek at gcc dot gnu.org
  2013-10-03 10:36 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-10-03 10:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r180707.


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

* [Bug c++/58597] [c++11] ICE with lambda in default argument of template function
  2013-10-02 20:25 [Bug c++/58597] New: [c++11] ICE with lambda in default argument of template function reichelt at gcc dot gnu.org
  2013-10-03 10:36 ` [Bug c++/58597] " mpolacek at gcc dot gnu.org
@ 2013-10-03 10:36 ` mpolacek at gcc dot gnu.org
  2013-10-04  1:12 ` paolo.carlini at oracle dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-10-03 10:36 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-10-03
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org
     Ever confirmed|0                           |1


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

* [Bug c++/58597] [c++11] ICE with lambda in default argument of template function
  2013-10-02 20:25 [Bug c++/58597] New: [c++11] ICE with lambda in default argument of template function reichelt at gcc dot gnu.org
  2013-10-03 10:36 ` [Bug c++/58597] " mpolacek at gcc dot gnu.org
  2013-10-03 10:36 ` mpolacek at gcc dot gnu.org
@ 2013-10-04  1:12 ` paolo.carlini at oracle dot com
  2015-01-14  8:02 ` reichelt at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-04  1:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Now, Marek, since this is known to fail even with 4.5.0 (with -std=c++0x of
course) there is definitely something wrong with your pointing to r180707.

I wonder if the fact that before r180707 one couldn't use -std=c++11, had to
use -std=c++0x, is somehow fooling your scripts...


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

* [Bug c++/58597] [c++11] ICE with lambda in default argument of template function
  2013-10-02 20:25 [Bug c++/58597] New: [c++11] ICE with lambda in default argument of template function reichelt at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2013-10-04  1:12 ` paolo.carlini at oracle dot com
@ 2015-01-14  8:02 ` reichelt at gcc dot gnu.org
  2015-01-16 16:52 ` [Bug c++/58597] [5.0 Regression] " paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: reichelt at gcc dot gnu.org @ 2015-01-14  8:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Volker Reichelt <reichelt at gcc dot gnu.org> ---
The ICE disappered on the 4.9 branch in GCC 4.9.2.
But the testcase still crashes trunk with a different stack trace:


bug.cc:6:12: internal compiler error: Segmentation fault
 A<int> a = 0;
            ^
0xcdc42f crash_signal
        ../../gcc/gcc/toplev.c:372
0x6943ae tsubst_default_argument(tree_node*, tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/pt.c:10496
0x629f9f convert_default_arg(tree_node*, tree_node*, tree_node*, int, int)
        ../../gcc/gcc/cp/call.c:6774
0x62a91d build_over_call
        ../../gcc/gcc/cp/call.c:7301
0x62f9b4 convert_like_real
        ../../gcc/gcc/cp/call.c:6253
0x62f799 convert_like_real
        ../../gcc/gcc/cp/call.c:6384
0x6395d7 build_user_type_conversion(tree_node*, tree_node*, int, int)
        ../../gcc/gcc/cp/call.c:3831
0x78897e ocp_convert(tree_node*, tree_node*, int, int, int)
        ../../gcc/gcc/cp/cvt.c:875
0x7969f5 expand_default_init
        ../../gcc/gcc/cp/init.c:1661
0x7969f5 expand_aggr_init_1
        ../../gcc/gcc/cp/init.c:1830
0x7971e4 build_aggr_init(tree_node*, tree_node*, int, int)
        ../../gcc/gcc/cp/init.c:1582
0x66cddc build_aggr_init_full_exprs
        ../../gcc/gcc/cp/decl.c:5780
0x66cddc check_initializer
        ../../gcc/gcc/cp/decl.c:5924
0x66e79c cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ../../gcc/gcc/cp/decl.c:6607
0x756539 cp_parser_init_declarator
        ../../gcc/gcc/cp/parser.c:17290
0x758185 cp_parser_simple_declaration
        ../../gcc/gcc/cp/parser.c:11600
0x7585b3 cp_parser_block_declaration
        ../../gcc/gcc/cp/parser.c:11474
0x760689 cp_parser_declaration
        ../../gcc/gcc/cp/parser.c:11371
0x76098a cp_parser_declaration_seq_opt
        ../../gcc/gcc/cp/parser.c:11257
0x760cc7 cp_parser_translation_unit
        ../../gcc/gcc/cp/parser.c:4108
Please submit a full bug report, [etc.]


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

* [Bug c++/58597] [5.0 Regression] ICE with lambda in default argument of template function
  2013-10-02 20:25 [Bug c++/58597] New: [c++11] ICE with lambda in default argument of template function reichelt at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2015-01-14  8:02 ` reichelt at gcc dot gnu.org
@ 2015-01-16 16:52 ` paolo.carlini at oracle dot com
  2015-01-27 21:41 ` [Bug c++/58597] [5 " jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-01-16 16:52 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.9.2
            Summary|[c++11] ICE with lambda in  |[5.0 Regression] ICE with
                   |default argument of         |lambda in default argument
                   |template function           |of template function

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Thus a regression.


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

* [Bug c++/58597] [5 Regression] ICE with lambda in default argument of template function
  2013-10-02 20:25 [Bug c++/58597] New: [c++11] ICE with lambda in default argument of template function reichelt at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2015-01-16 16:52 ` [Bug c++/58597] [5.0 Regression] " paolo.carlini at oracle dot com
@ 2015-01-27 21:41 ` jason at gcc dot gnu.org
  2015-01-27 23:21 ` jason at gcc dot gnu.org
  2015-01-28 17:36 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2015-01-27 21:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Tue Jan 27 21:40:45 2015
New Revision: 220192

URL: https://gcc.gnu.org/viewcvs?rev=220192&root=gcc&view=rev
Log:
    PR c++/58597
    * lambda.c (maybe_add_lambda_conv_op): Check cfun rather than
    current_function_decl.

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


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

* [Bug c++/58597] [5 Regression] ICE with lambda in default argument of template function
  2013-10-02 20:25 [Bug c++/58597] New: [c++11] ICE with lambda in default argument of template function reichelt at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2015-01-27 21:41 ` [Bug c++/58597] [5 " jason at gcc dot gnu.org
@ 2015-01-27 23:21 ` jason at gcc dot gnu.org
  2015-01-28 17:36 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2015-01-27 23:21 UTC (permalink / raw)
  To: gcc-bugs

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

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

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


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

* [Bug c++/58597] [5 Regression] ICE with lambda in default argument of template function
  2013-10-02 20:25 [Bug c++/58597] New: [c++11] ICE with lambda in default argument of template function reichelt at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2015-01-27 23:21 ` jason at gcc dot gnu.org
@ 2015-01-28 17:36 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2015-01-28 17:36 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed.


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

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

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-02 20:25 [Bug c++/58597] New: [c++11] ICE with lambda in default argument of template function reichelt at gcc dot gnu.org
2013-10-03 10:36 ` [Bug c++/58597] " mpolacek at gcc dot gnu.org
2013-10-03 10:36 ` mpolacek at gcc dot gnu.org
2013-10-04  1:12 ` paolo.carlini at oracle dot com
2015-01-14  8:02 ` reichelt at gcc dot gnu.org
2015-01-16 16:52 ` [Bug c++/58597] [5.0 Regression] " paolo.carlini at oracle dot com
2015-01-27 21:41 ` [Bug c++/58597] [5 " jason at gcc dot gnu.org
2015-01-27 23:21 ` jason at gcc dot gnu.org
2015-01-28 17:36 ` jason 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).