[Bug c++/71251] New: ICE on invalid code, with unusual template name

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

[Bug c++/71251] New: ICE on invalid code, with unusual template name

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

            Bug ID: 71251
           Summary: ICE on invalid code, with unusual template name
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rippey.e at gmail dot com
  Target Milestone: ---

With g++ trunk this code:

template<int,int>
template<typename>
using U=void;

template<typename,typename>
struct S1;

template<typename T>
struct S1<T,U<T>>{
        template<typename>
        struct S2:S2<T>{};
};

produces the following error message:

b1.cpp:11:16: internal compiler error: tree check: accessed elt 2 of tree_vec
with 1 elts in tsubst, at cp/pt.c:12961
  struct S2:S2<T>{};
                ^
0x100f665 tree_vec_elt_check_failed(int, int, char const*, int, char const*)
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/tree.c:9950
0x722439 tree_vec_elt_check(tree_node const*, int, char const*, int, char
const*)
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/tree.h:3477
0x6ea386 tsubst(tree_node*, tree_node*, int, tree_node*)
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/pt.c:12961
0x6e0dc0 tsubst_copy
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/pt.c:14077
0x6e679b tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/pt.c:17161
0x6db38a tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/pt.c:15800
0x6fc6ea tsubst_template_args
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/pt.c:11223
0x6fc9d2 tsubst_template_args
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/pt.c:11183
0x6e9aac tsubst(tree_node*, tree_node*, int, tree_node*)
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/pt.c:13213
0x6e9db8 tsubst(tree_node*, tree_node*, int, tree_node*)
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/pt.c:12836
0x6fc6ea tsubst_template_args
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/pt.c:11223
0x7011e4 tsubst_aggr_type
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/pt.c:11420
0x6e9bd1 tsubst(tree_node*, tree_node*, int, tree_node*)
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/pt.c:12889
0x6fe4ec lookup_template_class_1
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/pt.c:8366
0x6fe4ec lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/pt.c:8638
0x811b9d finish_template_type(tree_node*, tree_node*, int)
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/semantics.c:3137
0x79d143 cp_parser_template_id
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/parser.c:14913
0x79d3fa cp_parser_class_name
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/parser.c:21210
0x78e6a1 cp_parser_qualifying_entity
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/parser.c:6238
0x78e6a1 cp_parser_nested_name_specifier_opt
        /disk/0/erippey/gcc/b/objdir/../gcc/gcc/cp/parser.c:5924
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.

This appears to be a regression.  The above code works on version 4.8.5 (though
it does require "--std=c++11" there).
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71251] [5/6/7 regression] ICE on invalid code, with unusual template name

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |4.9.3
           Keywords|                            |ice-on-invalid-code
   Last reconfirmed|                            |2016-05-26
                 CC|                            |msebor at gcc dot gnu.org
     Ever confirmed|0                           |1
            Summary|ICE on invalid code, with   |[5/6/7 regression] ICE on
                   |unusual template name       |invalid code, with unusual
                   |                            |template name
      Known to fail|                            |5.1.0, 6.1.0, 7.0

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed with today's trunk, GCC 6 and GCC 5.  GCC 4.9.3 accepts the invalid
code (invalid due to the double template <...> in the alias template
declaration).  Current trunk also accepts the declaration alone.  Clang rejects
it but EDG eccp 4.10 also accepts it, making me wonder if I'm missing something
about the validity of the construct.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71251] [5/6/7 regression] ICE on invalid code, with unusual template name

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=71251

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

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

[Bug c++/71251] [5/6/7 regression] ICE on invalid code, with unusual template name

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=71251

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|5.4                         |5.5

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 5.4 is being released, adjusting target milestone.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71251] [5/6/7 regression] ICE on invalid code, with unusual template name

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=71251

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71251] [5/6/7 regression] ICE on invalid code, with unusual template name

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=71251

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
ICE started with r217250.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71251] [5/6/7/8 regression] ICE on invalid code, with unusual template name

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=71251

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

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

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

[Bug c++/71251] [6/7/8 regression] ICE on invalid code, with unusual template name

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=71251

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

[Bug c++/71251] [6/7/8 regression] ICE on invalid code, with unusual template name

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=71251

Alexandre Oliva <aoliva at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |aoliva at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |aoliva at gcc dot gnu.org

--- Comment #6 from Alexandre Oliva <aoliva at gcc dot gnu.org> ---
Created attachment 43689
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43689&action=edit
candidate patch

Mine.  Here's the patch I'm testing.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71251] [6/7/8 regression] ICE on invalid code, with unusual template name

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=71251

Alexandre Oliva <aoliva at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch

--- Comment #7 from Alexandre Oliva <aoliva at gcc dot gnu.org> ---
Patch posted, unchanged.
https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00837.html
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71251] [6/7/8 regression] ICE on invalid code, with unusual template name

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=71251

--- Comment #8 from Alexandre Oliva <aoliva at gcc dot gnu.org> ---
Author: aoliva
Date: Fri Mar 23 04:09:06 2018
New Revision: 258793

URL: https://gcc.gnu.org/viewcvs?rev=258793&root=gcc&view=rev
Log:
[PR c++/71251] check tmpl parms in template using decl

Check that template using decls have the correct number of parm lists.

for  gcc/cp/ChangeLog

        PR c++/71251
        * parser.c (cp_parser_alias_declaration): Call
        parser_check_template_parameters.

for  gcc/testsuite/ChangeLog

        PR c++/71251
        * g++.dg/cpp0x/pr71251.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr71251.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71251] [6/7 regression] ICE on invalid code, with unusual template name

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=71251

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

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

--- Comment #9 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++/71251] [7 regression] ICE on invalid code, with unusual template name

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=71251

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++/71251] [7 regression] ICE on invalid code, with unusual template name

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=71251

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

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

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