public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97975] New: ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr
@ 2020-11-24 18:34 gscfq@t-online.de
  2020-11-25  8:12 ` [Bug c++/97975] " marxin at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gscfq@t-online.de @ 2020-11-24 18:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97975
           Summary: ICE unexpected expression '(int)A<
                    <template-parameter-1-1> >::b' of kind
                    implicit_conv_expr
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Seems to be an old issue :


$ cat z1.cc
template <class> class A
{
  static const float b;
  static inline const int c = b;
};


$ g++-11-20201122 -c z1.cc
z1.cc:4:31: internal compiler error: unexpected expression '(int)A<
<template-parameter-1-1> >::b' of kind implicit_conv_expr
    4 |   static inline const int c = b;
      |                               ^
0x6f5185 cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:6647
0x6f6b37 cxx_eval_outermost_constant_expr
        ../../gcc/cp/constexpr.c:6856
0x6fbf8f maybe_constant_init_1
        ../../gcc/cp/constexpr.c:7307
0x96811c store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ../../gcc/cp/typeck2.c:760
0x74fc6e check_initializer
        ../../gcc/cp/decl.c:6923
0x77f0ab cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ../../gcc/cp/decl.c:7713
0x793bd3 finish_static_data_member_decl(tree_node*, tree_node*, bool,
tree_node*, int)
        ../../gcc/cp/decl2.c:814
0x79477e grokfield(cp_declarator const*, cp_decl_specifier_seq*, tree_node*,
bool, tree_node*, tree_node*)
        ../../gcc/cp/decl2.c:1000
0x85f9f4 cp_parser_member_declaration
        ../../gcc/cp/parser.c:25861
0x82f722 cp_parser_member_specification_opt
        ../../gcc/cp/parser.c:25306
0x82f722 cp_parser_class_specifier_1
        ../../gcc/cp/parser.c:24395
0x832159 cp_parser_class_specifier
        ../../gcc/cp/parser.c:24706
0x832159 cp_parser_type_specifier
        ../../gcc/cp/parser.c:17962
0x832d86 cp_parser_decl_specifier_seq
        ../../gcc/cp/parser.c:14584
0x85e0f5 cp_parser_single_declaration
        ../../gcc/cp/parser.c:29906
0x85e4b5 cp_parser_template_declaration_after_parameters
        ../../gcc/cp/parser.c:29570
0x85f07f cp_parser_explicit_template_declaration
        ../../gcc/cp/parser.c:29835
0x85f07f cp_parser_template_declaration_after_export
        ../../gcc/cp/parser.c:29854
0x8613a9 cp_parser_declaration
        ../../gcc/cp/parser.c:13608
0x861cf8 cp_parser_translation_unit
        ../../gcc/cp/parser.c:4806

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

* [Bug c++/97975] ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr
  2020-11-24 18:34 [Bug c++/97975] New: ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr gscfq@t-online.de
@ 2020-11-25  8:12 ` marxin at gcc dot gnu.org
  2020-12-01  2:58 ` [Bug c++/97975] [8/9/10/11 Regression] " mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-11-25  8:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |marxin at gcc dot gnu.org
   Last reconfirmed|                            |2020-11-25

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
At least as old as 4.8.0.

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

* [Bug c++/97975] [8/9/10/11 Regression] ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr
  2020-11-24 18:34 [Bug c++/97975] New: ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr gscfq@t-online.de
  2020-11-25  8:12 ` [Bug c++/97975] " marxin at gcc dot gnu.org
@ 2020-12-01  2:58 ` mpolacek at gcc dot gnu.org
  2020-12-01  2:58 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-12-01  2:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
   Target Milestone|---                         |8.5
             Status|NEW                         |ASSIGNED
            Summary|ICE unexpected expression   |[8/9/10/11 Regression] ICE
                   |'(int)A<                    |unexpected expression
                   |<template-parameter-1-1>    |'(int)A<
                   |>::b' of kind               |<template-parameter-1-1>
                   |implicit_conv_expr          |>::b' of kind
                   |                            |implicit_conv_expr

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r249382, actually.  I think I have a patch.

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

* [Bug c++/97975] [8/9/10/11 Regression] ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr
  2020-11-24 18:34 [Bug c++/97975] New: ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr gscfq@t-online.de
  2020-11-25  8:12 ` [Bug c++/97975] " marxin at gcc dot gnu.org
  2020-12-01  2:58 ` [Bug c++/97975] [8/9/10/11 Regression] " mpolacek at gcc dot gnu.org
@ 2020-12-01  2:58 ` mpolacek at gcc dot gnu.org
  2020-12-02 19:39 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-12-01  2:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug c++/97975] [8/9/10/11 Regression] ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr
  2020-11-24 18:34 [Bug c++/97975] New: ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2020-12-01  2:58 ` mpolacek at gcc dot gnu.org
@ 2020-12-02 19:39 ` cvs-commit at gcc dot gnu.org
  2020-12-02 19:40 ` [Bug c++/97975] [8/9/10 " mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-12-02 19:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:69bf1c7d5ee21392334f1982d1b40c38e103bbd4

commit r11-5678-g69bf1c7d5ee21392334f1982d1b40c38e103bbd4
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Dec 1 10:39:08 2020 -0500

    c++: Fix ICE with inline variable in template [PR97975]

    In this test, we have

      static inline const int c = b;

    in a class template, and we call store_init_value as usual.  There, the
    value is

      IMPLICIT_CONV_EXPR<const float>(b)

    which is is_nondependent_static_init_expression but isn't
    is_nondependent_constant_expression (they only differ in STRICT).
    We call fold_non_dependent_expr, but that just returns the expression
    because it only instantiates is_nondependent_constant_expression
    expressions.  Since we're not checking the initializer of a constexpr
    variable, we go on to call maybe_constant_init, whereupon we crash
    because it tries to evaluate all is_nondependent_static_init_expression
    expressions, which our value is, but it still contains a template code.

    I think the fix is to call fold_non_dependent_init instead of
    maybe_constant_init, and only call fold_non_dependent_expr on the
    "this is a constexpr variable" path so as to avoid instantiating twice
    in a row.  Outside a template this should also avoid evaluating the
    value twice.

    gcc/cp/ChangeLog:

            PR c++/97975
            * constexpr.c (fold_non_dependent_init): Add a tree parameter.
            Use it.
            * cp-tree.h (fold_non_dependent_init): Add a tree parameter with
            a default value.
            * typeck2.c (store_init_value): Call fold_non_dependent_expr
            only when checking the initializer for constexpr variables.
            Call fold_non_dependent_init instead of maybe_constant_init.

    gcc/testsuite/ChangeLog:

            PR c++/97975
            * g++.dg/cpp1z/inline-var8.C: New test.

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

* [Bug c++/97975] [8/9/10 Regression] ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr
  2020-11-24 18:34 [Bug c++/97975] New: ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2020-12-02 19:39 ` cvs-commit at gcc dot gnu.org
@ 2020-12-02 19:40 ` mpolacek at gcc dot gnu.org
  2021-01-05 21:31 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-12-02 19:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[8/9/10/11 Regression] ICE  |[8/9/10 Regression] ICE
                   |unexpected expression       |unexpected expression
                   |'(int)A<                    |'(int)A<
                   |<template-parameter-1-1>    |<template-parameter-1-1>
                   |>::b' of kind               |>::b' of kind
                   |implicit_conv_expr          |implicit_conv_expr

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed on trunk so far.

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

* [Bug c++/97975] [8/9/10 Regression] ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr
  2020-11-24 18:34 [Bug c++/97975] New: ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2020-12-02 19:40 ` [Bug c++/97975] [8/9/10 " mpolacek at gcc dot gnu.org
@ 2021-01-05 21:31 ` cvs-commit at gcc dot gnu.org
  2021-01-05 21:36 ` [Bug c++/97975] [8/9 " mpolacek at gcc dot gnu.org
  2024-03-26 17:19 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-05 21:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:d0684e49ee8d859fc527b22aaaaed206930371a3

commit r10-9207-gd0684e49ee8d859fc527b22aaaaed206930371a3
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Dec 1 10:39:08 2020 -0500

    c++: Fix ICE with inline variable in template [PR97975]

    In this test, we have

      static inline const int c = b;

    in a class template, and we call store_init_value as usual.  There, the
    value is

      IMPLICIT_CONV_EXPR<const float>(b)

    which is is_nondependent_static_init_expression but isn't
    is_nondependent_constant_expression (they only differ in STRICT).
    We call fold_non_dependent_expr, but that just returns the expression
    because it only instantiates is_nondependent_constant_expression
    expressions.  Since we're not checking the initializer of a constexpr
    variable, we go on to call maybe_constant_init, whereupon we crash
    because it tries to evaluate all is_nondependent_static_init_expression
    expressions, which our value is, but it still contains a template code.

    I think the fix is to call fold_non_dependent_init instead of
    maybe_constant_init, and only call fold_non_dependent_expr on the
    "this is a constexpr variable" path so as to avoid instantiating twice
    in a row.  Outside a template this should also avoid evaluating the
    value twice.

    gcc/cp/ChangeLog:

            PR c++/97975
            * constexpr.c (fold_non_dependent_init): Add a tree parameter.
            Use it.
            * cp-tree.h (fold_non_dependent_init): Add a tree parameter with
            a default value.
            * typeck2.c (store_init_value): Call fold_non_dependent_expr
            only when checking the initializer for constexpr variables.
            Call fold_non_dependent_init instead of maybe_constant_init.

    gcc/testsuite/ChangeLog:

            PR c++/97975
            * g++.dg/cpp1z/inline-var8.C: New test.

    (cherry picked from commit 69bf1c7d5ee21392334f1982d1b40c38e103bbd4)

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

* [Bug c++/97975] [8/9 Regression] ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr
  2020-11-24 18:34 [Bug c++/97975] New: ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2021-01-05 21:31 ` cvs-commit at gcc dot gnu.org
@ 2021-01-05 21:36 ` mpolacek at gcc dot gnu.org
  2024-03-26 17:19 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-01-05 21:36 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[8/9/10 Regression] ICE     |[8/9 Regression] ICE
                   |unexpected expression       |unexpected expression
                   |'(int)A<                    |'(int)A<
                   |<template-parameter-1-1>    |<template-parameter-1-1>
                   |>::b' of kind               |>::b' of kind
                   |implicit_conv_expr          |implicit_conv_expr
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed in GCC 10 too.

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

* [Bug c++/97975] [8/9 Regression] ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr
  2020-11-24 18:34 [Bug c++/97975] New: ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2021-01-05 21:36 ` [Bug c++/97975] [8/9 " mpolacek at gcc dot gnu.org
@ 2024-03-26 17:19 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-26 17:19 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |10.2.0
      Known to work|                            |10.3.0
   Target Milestone|8.5                         |10.3

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

end of thread, other threads:[~2024-03-26 17:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-24 18:34 [Bug c++/97975] New: ICE unexpected expression '(int)A< <template-parameter-1-1> >::b' of kind implicit_conv_expr gscfq@t-online.de
2020-11-25  8:12 ` [Bug c++/97975] " marxin at gcc dot gnu.org
2020-12-01  2:58 ` [Bug c++/97975] [8/9/10/11 Regression] " mpolacek at gcc dot gnu.org
2020-12-01  2:58 ` mpolacek at gcc dot gnu.org
2020-12-02 19:39 ` cvs-commit at gcc dot gnu.org
2020-12-02 19:40 ` [Bug c++/97975] [8/9/10 " mpolacek at gcc dot gnu.org
2021-01-05 21:31 ` cvs-commit at gcc dot gnu.org
2021-01-05 21:36 ` [Bug c++/97975] [8/9 " mpolacek at gcc dot gnu.org
2024-03-26 17:19 ` pinskia 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).