[Bug c++/77522] New: ICE on invalid code C++14 code: in tsubst_decl, at cp/pt.c:12447

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug c++/77522] New: ICE on invalid code C++14 code: in tsubst_decl, at cp/pt.c:12447

thiago at kde dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77522

            Bug ID: 77522
           Summary: ICE on invalid code C++14 code: in tsubst_decl, at
                    cp/pt.c:12447
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu
  Target Milestone: ---

It affects 4.9.x and later, which have C++14 support.


$ g++-trunk -c -std=c++14 small.cpp
small.cpp: In instantiation of ‘f(T)::<lambda()> [with T = int]’:
small.cpp:3:18:   required from ‘struct f(T) [with T = int]::<lambda()>’
small.cpp:3:8:   required from ‘void f(T) [with T = int]’
small.cpp:8:7:   required from here
small.cpp:3:24: error: use of ‘f(T) [with T = int]::<lambda()>::__a’ before
deduction of ‘auto’
   auto g = [&a = f] () {};
                        ^
small.cpp:3:24: error: use of ‘f(T) [with T = int]::<lambda()>::__a’ before
deduction of ‘auto’
small.cpp:3:24: internal compiler error: in tsubst_decl, at cp/pt.c:12447
0x6fe7c6 tsubst_decl
        ../../gcc-source-trunk/gcc/cp/pt.c:12447
0x6f32de tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc-source-trunk/gcc/cp/pt.c:12907
0x6e07fa tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:15284
0x6dfa43 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:15419
0x6dd120 instantiate_decl(tree_node*, int, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:22159
0x7266b5 instantiate_class_template_1
        ../../gcc-source-trunk/gcc/cp/pt.c:10346
0x7266b5 instantiate_class_template(tree_node*)
        ../../gcc-source-trunk/gcc/cp/pt.c:10416
0x7cbf13 complete_type(tree_node*)
        ../../gcc-source-trunk/gcc/cp/typeck.c:133
0x6eaf2c tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:17269
0x6df247 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:15936
0x5df520 tsubst_init
        ../../gcc-source-trunk/gcc/cp/pt.c:13966
0x6e3144 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:15334
0x6dec3b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:15228
0x6dfa43 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:15419
0x6dd120 instantiate_decl(tree_node*, int, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:22159
0x72a5f2 instantiate_pending_templates(int)
        ../../gcc-source-trunk/gcc/cp/pt.c:22278
0x76f597 c_parse_final_cleanups()
        ../../gcc-source-trunk/gcc/cp/decl2.c:4617
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.
$


-----------------------------------------


template < class T = int > void f (T)
{
  auto g = [&a = f] () {};
}

int main ()
{
  f (0);
  return 0;
}
Reply | Threaded
Open this post in threaded view
|

[Bug c++/77522] ICE on invalid code C++14 code: in tsubst_decl, at cp/pt.c:12447

thiago at kde dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77522

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-09-10
                 CC|                            |marxin at gcc dot gnu.org
   Target Milestone|---                         |5.5
     Ever confirmed|0                           |1

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/77522] ICE on invalid code C++14 code: in tsubst_decl, at cp/pt.c:12447

thiago at kde dot org
In reply to this post by thiago at kde dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77522

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|5.5                         |---
Reply | Threaded
Open this post in threaded view
|

[Bug c++/77522] [5/6/7 Regression] ICE on invalid code C++14 code: in tsubst_decl, at cp/pt.c:12447

thiago at kde dot org
In reply to this post by thiago at kde dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77522

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org
   Target Milestone|---                         |5.5
            Summary|ICE on invalid code C++14   |[5/6/7 Regression] ICE on
                   |code: in tsubst_decl, at    |invalid code C++14 code: in
                   |cp/pt.c:12447               |tsubst_decl, at
                   |                            |cp/pt.c:12447

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r210017.  Before that it has been rejected:
pr77522.C: In function ‘void f(T)’:
pr77522.C:3:18: error: cannot capture ‘f’ by reference
   auto g = [&a = f] () {};
                  ^
pr77522.C: In instantiation of ‘struct f(T) [with T = int]::<lambda>’:
pr77522.C:3:25:   required from ‘void f(T) [with T = int]’
pr77522.C:8:7:   required from here
pr77522.C:3:18: error: unable to deduce ‘auto’ from ‘f’
pr77522.C:3:18: error: using invalid field ‘f(T)::<lambda()>::a’
Reply | Threaded
Open this post in threaded view
|

[Bug c++/77522] [5/6/7 Regression] ICE on invalid code C++14 code: in tsubst_decl, at cp/pt.c:12447

thiago at kde dot org
In reply to this post by thiago at kde dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77522

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |error-recovery
           Priority|P3                          |P4
Reply | Threaded
Open this post in threaded view
|

[Bug c++/77522] [6/7/8 Regression] ICE on invalid code C++14 code: in tsubst_decl, at cp/pt.c:12447

thiago at kde dot org
In reply to this post by thiago at kde dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77522

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|5.5                         |6.5
Reply | Threaded
Open this post in threaded view
|

[Bug c++/77522] [6/7/8 Regression] ICE on invalid code C++14 code: in tsubst_decl, at cp/pt.c:12447

thiago at kde dot org
In reply to this post by thiago at kde dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77522

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmalcolm at gcc dot gnu.org,
                   |                            |paolo.carlini at oracle dot com

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
In trunk we don't ICE anymore on this, I think we can safely remove the 8
Regression marker and commit a testcase. I'm wondering however why when
initialize_reference calls error_at the input_location is at the open square
bracket. Well, just a curiosity, at some point expr itself will have its own
usable location.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/77522] [6/7/8 Regression] ICE on invalid code C++14 code: in tsubst_decl, at cp/pt.c:12447

thiago at kde dot org
In reply to this post by thiago at kde dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77522

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The ICE got fixed with r251433.  Since then the error is:
pr77522.C: In instantiation of ‘void f(T) [with T = int]’:
pr77522.C:8:7:   required from here
pr77522.C:3:8: error: use of ‘f(T) [with T = int]::<lambda()>::__a’ before
deduction of ‘auto’
   auto g = [&a = f] () {};
        ^
pr77522.C:3:12: error: invalid initialization of non-const reference of type
‘auto&’ from an rvalue of type ‘<unresolved overloaded function type>’
   auto g = [&a = f] () {};
            ^

Paolo, will you check the testcase in and remove 8 Regression?
Reply | Threaded
Open this post in threaded view
|

[Bug c++/77522] [6/7/8 Regression] ICE on invalid code C++14 code: in tsubst_decl, at cp/pt.c:12447

thiago at kde dot org
In reply to this post by thiago at kde dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77522

--- Comment #5 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Fri Feb  9 11:37:14 2018
New Revision: 257521

URL: https://gcc.gnu.org/viewcvs?rev=257521&root=gcc&view=rev
Log:
2018-02-09  Paolo Carlini  <[hidden email]>

        PR c++/77522
        * g++.dg/cpp1y/lambda-init16.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp1y/lambda-init16.C
Modified:
    trunk/gcc/testsuite/ChangeLog
Reply | Threaded
Open this post in threaded view
|

[Bug c++/77522] [6/7 Regression] ICE on invalid code C++14 code: in tsubst_decl, at cp/pt.c:12447

thiago at kde dot org
In reply to this post by thiago at kde dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77522

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|paolo.carlini at oracle dot com    |
            Summary|[6/7/8 Regression] ICE on   |[6/7 Regression] ICE on
                   |invalid code C++14 code: in |invalid code C++14 code: in
                   |tsubst_decl, at             |tsubst_decl, at
                   |cp/pt.c:12447               |cp/pt.c:12447

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Done.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/77522] [6/7 Regression] ICE on invalid code C++14 code: in tsubst_decl, at cp/pt.c:12447

thiago at kde dot org
In reply to this post by thiago at kde dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77522

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|6.5                         |7.4

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 6 branch is being closed
Reply | Threaded
Open this post in threaded view
|

[Bug c++/77522] [7 Regression] ICE on invalid code C++14 code: in tsubst_decl, at cp/pt.c:12447

thiago at kde dot org
In reply to this post by thiago at kde dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77522

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|7.4                         |7.5
Reply | Threaded
Open this post in threaded view
|

[Bug c++/77522] [7 Regression] ICE on invalid code C++14 code: in tsubst_decl, at cp/pt.c:12447

thiago at kde dot org
In reply to this post by thiago at kde dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77522

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
      Known to work|                            |8.0
         Resolution|---                         |FIXED
   Target Milestone|7.5                         |8.0
      Known to fail|                            |7.5.0

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed in GCC8.