[Bug c++/71169] New: [7 Regression] ICE on invalid C++ code in pop_nested_class (cp/class.c:7785)

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

[Bug c++/71169] New: [7 Regression] ICE on invalid C++ code in pop_nested_class (cp/class.c:7785)

ian at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71169

            Bug ID: 71169
           Summary: [7 Regression] ICE on invalid C++ code in
                    pop_nested_class (cp/class.c:7785)
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
  Target Milestone: ---

Hi.

Follow code was created during reduction of a different problem:

$ cat invalid.cc
template <Preconditioner> class A {
  template <class = int> m_fn1() {
  m_fn1()
  }
}

$ invalid.cc:1:11: error: ‘Preconditioner’ has not been declared
 template <Preconditioner> class A {
           ^~~~~~~~~~~~~~
invalid.cc:2:32: error: ISO C++ forbids declaration of ‘m_fn1’ with no type
[-fpermissive]
   template <class = int> m_fn1() {
                                ^
invalid.cc:5:1: error: expected ‘;’ after class definition
 }
 ^
invalid.cc: In substitution of ‘template<<typeprefixerror><anonymous> >
template<class> int A<<anonymous> >::m_fn1() [with <template-parameter-2-1> =
<missing>; <typeprefixerror><anonymous> = int]’:
invalid.cc:3:9:   required from here
invalid.cc:3:9: internal compiler error: Segmentation fault
   m_fn1()
         ^
0xd7d93f crash_signal
        ../../gcc/toplev.c:333
0x731f03 tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
        ../../gcc/tree.h:3147
0x731f03 pop_nested_class()
        ../../gcc/cp/class.c:7785
0x6f6ede instantiate_template_1
        ../../gcc/cp/pt.c:17400
0x6f6ede instantiate_template(tree_node*, tree_node*, int)
        ../../gcc/cp/pt.c:17449
0x7084d7 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, bool, bool)
        ../../gcc/cp/pt.c:17808
0x66ddd0 add_template_candidate_real
        ../../gcc/cp/call.c:3110
0x66eb2c add_template_candidate
        ../../gcc/cp/call.c:3188
0x66eb2c add_candidates
        ../../gcc/cp/call.c:5361
0x66f3af build_new_method_call_1
        ../../gcc/cp/call.c:8312
0x66f3af 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:8511
0x784522 cp_parser_postfix_expression
        ../../gcc/cp/parser.c:6875
0x78205c cp_parser_unary_expression
        ../../gcc/cp/parser.c:7986
0x78c097 cp_parser_cast_expression
        ../../gcc/cp/parser.c:8663
0x78c65b cp_parser_binary_expression
        ../../gcc/cp/parser.c:8764
0x78cf20 cp_parser_assignment_expression
        ../../gcc/cp/parser.c:9051
0x78f84a cp_parser_expression
        ../../gcc/cp/parser.c:9220
0x78fdf3 cp_parser_expression_statement
        ../../gcc/cp/parser.c:10681
0x79f156 cp_parser_statement
        ../../gcc/cp/parser.c:10532
0x79fb3c cp_parser_statement_seq_opt
        ../../gcc/cp/parser.c:10804

GCC 6.1 works fine.

Martin
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71169] [7 Regression] ICE on invalid C++ code in pop_nested_class (cp/class.c:7785)

ian at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71169

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r236221:

Author: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri May 13 19:18:35 2016 +0000

        Fix type-dependence and the current instantiation.

        PR c++/10200
        PR c++/69753
        * pt.c (tsubst_decl): Use uses_template_parms.
        (instantiate_template_1): Handle non-dependent calls in templates.
        (value_dependent_expression_p): Handle BASELINK, FUNCTION_DECL.
        (type_dependent_expression_p): Only consider innermost template args.
        (dependent_template_arg_p): Check enclosing class of a template here.
        (dependent_template_p): Not here.
        (type_dependent_object_expression_p): New.
        * typeck.c (finish_class_member_access_expr): Use it.
        * parser.c (cp_parser_postfix_expression): Use it.
        (cp_parser_postfix_dot_deref_expression): Use it.  Use comptypes
        to detect the current instantiation.
        (cp_parser_lookup_name): Really implement DR 141.
        * search.c (lookup_field_r): Prefer a dependent using-declaration.
        (any_dependent_bases_p): Split out from...
        * name-lookup.c (do_class_using_decl): ...here.
        * call.c (build_new_method_call_1): Use it.
        * semantics.c (finish_call_expr): 'this' doesn't make a call dependent.
        * tree.c (non_static_member_function_p): Remove.
        * typeck2.c (build_x_arrow): Use dependent_scope_p.

Martin
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71169] [7 Regression] ICE on invalid C++ code in pop_nested_class (cp/class.c:7785)

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

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

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

[Bug c++/71169] [7 Regression] ICE on invalid C++ code in pop_nested_class (cp/class.c:7785)

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-06-08
     Ever confirmed|0                           |1
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71169] [7 Regression] ICE on invalid C++ code in pop_nested_class (cp/class.c:7785)

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

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++/71169] [7/8 Regression] ICE on invalid C++ code in pop_nested_class (cp/class.c:7785)

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|7.0                         |7.2

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 7.1 has been released.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71169] [7/8 Regression] ICE on invalid C++ code in pop_nested_class (cp/class.c:7785)

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|7.2 7.2                     |7.3 7.3

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 7.2 is being released, adjusting target milestone.

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

[Bug c++/71169] [7/8 Regression] ICE on invalid C++ code in pop_nested_class (cp/class.c:7785)

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|7.2 7.2                     |7.3 7.3

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 7.2 is being released, adjusting target milestone.

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

[Bug c++/71169] [7/8 Regression] ICE on invalid C++ code in pop_nested_class (cp/class.c:7785)

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

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

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

[Bug c++/71169] [7/8 Regression] ICE on invalid C++ code in pop_nested_class (cp/class.c:7785)

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

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

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

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

[Bug c++/71169] [7/8 Regression] ICE on invalid C++ code in pop_nested_class (cp/class.c:7785)

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |paolo.carlini at oracle dot com

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

[Bug c++/71169] [7/8 Regression] ICE on invalid C++ code in pop_nested_class (cp/class.c:7785)

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

--- Comment #5 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Fri Mar  9 23:03:06 2018
New Revision: 258401

URL: https://gcc.gnu.org/viewcvs?rev=258401&root=gcc&view=rev
Log:
/cp
2018-03-09  Jason Merrill  <[hidden email]>
            Paolo Carlini  <[hidden email]>

        PR c++/71169
        PR c++/71832
        * pt.c (any_erroneous_template_args_p): New.
        * cp-tree.h (any_erroneous_template_args_p): Declare it.
        * parser.c (cp_parser_class_specifier_1): Use it.

/testsuite
2018-03-09  Jason Merrill  <[hidden email]>
            Paolo Carlini  <[hidden email]>

        PR c++/71169
        PR c++/71832
        * g++.dg/cpp0x/pr71169.C: New.
        * g++.dg/cpp0x/pr71169-2.C: Likewise.
        * g++.dg/cpp0x/pr71832.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr71169-2.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr71169.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr71832.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71169] [7 Regression] ICE on invalid C++ code in pop_nested_class (cp/class.c:7785)

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[7/8 Regression] ICE on     |[7 Regression] ICE on
                   |invalid C++ code in         |invalid C++ code in
                   |pop_nested_class            |pop_nested_class
                   |(cp/class.c:7785)           |(cp/class.c:7785)

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

[Bug c++/71169] [7 Regression] ICE on invalid C++ code in pop_nested_class (cp/class.c:7785)

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

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++/71169] [7 Regression] ICE on invalid C++ code in pop_nested_class (cp/class.c:7785)

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

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 #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed in GCC8.