public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104284] New: [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr
@ 2022-01-29 20:35 dani at danielbertalan dot dev
  2022-01-29 21:40 ` [Bug c++/104284] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: dani at danielbertalan dot dev @ 2022-01-29 20:35 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104284
           Summary: [9/10/11/12 Regression] ICE: unexpected expression
                    '<anonymous>' of kind implicit_conv_expr
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dani at danielbertalan dot dev
  Target Milestone: ---

Godbolt link: https://godbolt.org/z/8bTPra5jK

The following code snippet causes an ICE on trunk (commit
3d41939c8799a51b1cd7f4610c06771bf6d52f15), and as far back as on 9.1 with
-fchecking=2:

---
struct EstablishedTiming {
    char m_dmt_id{};
};

auto x = [](auto) { constexpr EstablishedTiming
established_timings3_bytes[]{{}}; };
---

ice1.ii: In lambda function:
ice1.ii:5:80: internal compiler error: unexpected expression '<anonymous>' of
kind implicit_conv_expr
    5 | x = [](auto) { constexpr EstablishedTiming
established_timings3_bytes[]{{}}; };
      |                                                                        
  ^

0x98a181 cxx_eval_constant_expression
        gcc/cp/constexpr.cc:7493
0x99109b cxx_eval_store_expression
        gcc/cp/constexpr.cc:5619
0x9860b4 cxx_eval_constant_expression
        gcc/cp/constexpr.cc:6763
0x98a626 cxx_eval_outermost_constant_expr
        gcc/cp/constexpr.cc:7707
0x98f770 fold_non_dependent_expr_template
        gcc/cp/constexpr.cc:8066
0xb0de7f build_non_dependent_expr(tree_node*)
        gcc/cp/pt.cc:28412
0xb6c547 finish_expr_stmt(tree_node*)
        gcc/cp/semantics.cc:870
0xa2d933 get_temp_regvar(tree_node*, tree_node*)
        gcc/cp/init.cc:4254
0xa2d933 build_vec_init(tree_node*, tree_node*, tree_node*, bool, int, int,
vec<tree_node*, va_gc, vl_embed>**)
        gcc/cp/init.cc:4477
0xa2f503 build_aggr_init(tree_node*, tree_node*, int, int)
        gcc/cp/init.cc:2009
0x9d83ec build_aggr_init_full_exprs
        gcc/cp/decl.cc:7053
0x9d83ec check_initializer
        gcc/cp/decl.cc:7214
0x9fdc7f cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        gcc/cp/decl.cc:8108
0xaf15df cp_parser_init_declarator
        gcc/cp/parser.cc:22823
0xacb5e3 cp_parser_simple_declaration
        gcc/cp/parser.cc:15286
0xacd2fd cp_parser_declaration_statement
        gcc/cp/parser.cc:14367
0xacdaeb cp_parser_statement
        gcc/cp/parser.cc:12452
0xace9bd cp_parser_statement_seq_opt
        gcc/cp/parser.cc:12856
0xacea98 cp_parser_compound_statement
        gcc/cp/parser.cc:12808
0xacf797 cp_parser_function_body
        gcc/cp/parser.cc:25062

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

* [Bug c++/104284] [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr
  2022-01-29 20:35 [Bug c++/104284] New: [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr dani at danielbertalan dot dev
@ 2022-01-29 21:40 ` pinskia at gcc dot gnu.org
  2022-01-29 21:41 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-29 21:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-checking
   Target Milestone|---                         |9.5

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

* [Bug c++/104284] [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr
  2022-01-29 20:35 [Bug c++/104284] New: [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr dani at danielbertalan dot dev
  2022-01-29 21:40 ` [Bug c++/104284] " pinskia at gcc dot gnu.org
@ 2022-01-29 21:41 ` pinskia at gcc dot gnu.org
  2022-01-31  9:11 ` [Bug c++/104284] [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr since r9-6073-ge8b3c1bc3ba22dcf marxin at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-29 21:41 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-01-29
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/104284] [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr since r9-6073-ge8b3c1bc3ba22dcf
  2022-01-29 20:35 [Bug c++/104284] New: [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr dani at danielbertalan dot dev
  2022-01-29 21:40 ` [Bug c++/104284] " pinskia at gcc dot gnu.org
  2022-01-29 21:41 ` pinskia at gcc dot gnu.org
@ 2022-01-31  9:11 ` marxin at gcc dot gnu.org
  2022-03-09 13:20 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-01-31  9:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org
           Keywords|needs-bisection             |
            Summary|[9/10/11/12 Regression]     |[9/10/11/12 Regression]
                   |ICE: unexpected expression  |ICE: unexpected expression
                   |'<anonymous>' of kind       |'<anonymous>' of kind
                   |implicit_conv_expr          |implicit_conv_expr since
                   |                            |r9-6073-ge8b3c1bc3ba22dcf

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
With -std=c++17 it started with r9-6073-ge8b3c1bc3ba22dcf.

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

* [Bug c++/104284] [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr since r9-6073-ge8b3c1bc3ba22dcf
  2022-01-29 20:35 [Bug c++/104284] New: [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr dani at danielbertalan dot dev
                   ` (2 preceding siblings ...)
  2022-01-31  9:11 ` [Bug c++/104284] [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr since r9-6073-ge8b3c1bc3ba22dcf marxin at gcc dot gnu.org
@ 2022-03-09 13:20 ` rguenth at gcc dot gnu.org
  2022-03-10 17:55 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-03-09 13:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

* [Bug c++/104284] [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr since r9-6073-ge8b3c1bc3ba22dcf
  2022-01-29 20:35 [Bug c++/104284] New: [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr dani at danielbertalan dot dev
                   ` (3 preceding siblings ...)
  2022-03-09 13:20 ` rguenth at gcc dot gnu.org
@ 2022-03-10 17:55 ` mpolacek at gcc dot gnu.org
  2022-03-24 22:44 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-03-10 17:55 UTC (permalink / raw)
  To: gcc-bugs

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

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
             Status|NEW                         |ASSIGNED

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

* [Bug c++/104284] [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr since r9-6073-ge8b3c1bc3ba22dcf
  2022-01-29 20:35 [Bug c++/104284] New: [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr dani at danielbertalan dot dev
                   ` (4 preceding siblings ...)
  2022-03-10 17:55 ` mpolacek at gcc dot gnu.org
@ 2022-03-24 22:44 ` cvs-commit at gcc dot gnu.org
  2022-03-24 22:44 ` [Bug c++/104284] [9/10/11 " mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-24 22:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:9fdac7e16c940fb6264e6ddaf99c761f1a64a054

commit r12-7805-g9fdac7e16c940fb6264e6ddaf99c761f1a64a054
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Mar 17 14:39:37 2022 -0400

    c++: ICE with template code in constexpr [PR104284]

    Since r9-6073 cxx_eval_store_expression preevaluates the value to
    be stored, and that revealed a crash where a template code (here,
    code=IMPLICIT_CONV_EXPR) leaks into cxx_eval*.

    It happens because we're performing build_vec_init while processing
    a template, which calls get_temp_regvar which creates an INIT_EXPR.
    This INIT_EXPR's RHS contains an rvalue conversion so we create an
    IMPLICIT_CONV_EXPR.  Its operand is not type-dependent and the whole
    INIT_EXPR is not type-dependent.  So we call build_non_dependent_expr
    which, with -fchecking=2, calls fold_non_dependent_expr.  At this
    point the expression still has an IMPLICIT_CONV_EXPR, which ought to
    be handled in instantiate_non_dependent_expr_internal.  However,
    tsubst_copy_and_build doesn't handle INIT_EXPR; it will just call
    tsubst_copy which does nothing when args is null.  So we fail to
    replace the IMPLICIT_CONV_EXPR and ICE.

    The problem is that we call build_vec_init in a template in the
    first place.  We can avoid doing so by checking p_t_d before
    calling build_aggr_init in check_initializer.

            PR c++/104284

    gcc/cp/ChangeLog:

            * decl.cc (check_initializer): Don't call build_aggr_init in
            a template.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1y/constexpr-104284-1.C: New test.
            * g++.dg/cpp1y/constexpr-104284-2.C: New test.
            * g++.dg/cpp1y/constexpr-104284-3.C: New test.
            * g++.dg/cpp1y/constexpr-104284-4.C: New test.

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

* [Bug c++/104284] [9/10/11 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr since r9-6073-ge8b3c1bc3ba22dcf
  2022-01-29 20:35 [Bug c++/104284] New: [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr dani at danielbertalan dot dev
                   ` (5 preceding siblings ...)
  2022-03-24 22:44 ` cvs-commit at gcc dot gnu.org
@ 2022-03-24 22:44 ` mpolacek at gcc dot gnu.org
  2022-03-29  1:45 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-03-24 22:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[9/10/11/12 Regression]     |[9/10/11 Regression] ICE:
                   |ICE: unexpected expression  |unexpected expression
                   |'<anonymous>' of kind       |'<anonymous>' of kind
                   |implicit_conv_expr since    |implicit_conv_expr since
                   |r9-6073-ge8b3c1bc3ba22dcf   |r9-6073-ge8b3c1bc3ba22dcf

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

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

* [Bug c++/104284] [9/10/11 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr since r9-6073-ge8b3c1bc3ba22dcf
  2022-01-29 20:35 [Bug c++/104284] New: [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr dani at danielbertalan dot dev
                   ` (6 preceding siblings ...)
  2022-03-24 22:44 ` [Bug c++/104284] [9/10/11 " mpolacek at gcc dot gnu.org
@ 2022-03-29  1:45 ` cvs-commit at gcc dot gnu.org
  2022-03-29  1:48 ` [Bug c++/104284] [9/10 " mpolacek at gcc dot gnu.org
  2024-03-26 17:18 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-29  1:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:2a2b944c18936f9dfa880e8ff54906cfe90e89e8

commit r11-9713-g2a2b944c18936f9dfa880e8ff54906cfe90e89e8
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Mar 17 14:39:37 2022 -0400

    c++: ICE with template code in constexpr [PR104284]

    Since r9-6073 cxx_eval_store_expression preevaluates the value to
    be stored, and that revealed a crash where a template code (here,
    code=IMPLICIT_CONV_EXPR) leaks into cxx_eval*.

    It happens because we're performing build_vec_init while processing
    a template, which calls get_temp_regvar which creates an INIT_EXPR.
    This INIT_EXPR's RHS contains an rvalue conversion so we create an
    IMPLICIT_CONV_EXPR.  Its operand is not type-dependent and the whole
    INIT_EXPR is not type-dependent.  So we call build_non_dependent_expr
    which, with -fchecking=2, calls fold_non_dependent_expr.  At this
    point the expression still has an IMPLICIT_CONV_EXPR, which ought to
    be handled in instantiate_non_dependent_expr_internal.  However,
    tsubst_copy_and_build doesn't handle INIT_EXPR; it will just call
    tsubst_copy which does nothing when args is null.  So we fail to
    replace the IMPLICIT_CONV_EXPR and ICE.

    The problem is that we call build_vec_init in a template in the
    first place.  We can avoid doing so by checking p_t_d before
    calling build_aggr_init in check_initializer.

            PR c++/104284

    gcc/cp/ChangeLog:

            * decl.c (check_initializer): Don't call build_aggr_init in
            a template.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1y/constexpr-104284-1.C: New test.
            * g++.dg/cpp1y/constexpr-104284-2.C: New test.
            * g++.dg/cpp1y/constexpr-104284-3.C: New test.
            * g++.dg/cpp1y/constexpr-104284-4.C: New test.

    (cherry picked from commit 9fdac7e16c940fb6264e6ddaf99c761f1a64a054)

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

* [Bug c++/104284] [9/10 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr since r9-6073-ge8b3c1bc3ba22dcf
  2022-01-29 20:35 [Bug c++/104284] New: [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr dani at danielbertalan dot dev
                   ` (7 preceding siblings ...)
  2022-03-29  1:45 ` cvs-commit at gcc dot gnu.org
@ 2022-03-29  1:48 ` mpolacek at gcc dot gnu.org
  2024-03-26 17:18 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-03-29  1:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
            Summary|[9/10/11 Regression] ICE:   |[9/10 Regression] ICE:
                   |unexpected expression       |unexpected expression
                   |'<anonymous>' of kind       |'<anonymous>' of kind
                   |implicit_conv_expr since    |implicit_conv_expr since
                   |r9-6073-ge8b3c1bc3ba22dcf   |r9-6073-ge8b3c1bc3ba22dcf
             Status|ASSIGNED                    |RESOLVED

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

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

* [Bug c++/104284] [9/10 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr since r9-6073-ge8b3c1bc3ba22dcf
  2022-01-29 20:35 [Bug c++/104284] New: [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr dani at danielbertalan dot dev
                   ` (8 preceding siblings ...)
  2022-03-29  1:48 ` [Bug c++/104284] [9/10 " mpolacek at gcc dot gnu.org
@ 2024-03-26 17:18 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-26 17:18 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |11.3.0
      Known to fail|                            |11.2.0
   Target Milestone|9.5                         |11.3

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

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

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-29 20:35 [Bug c++/104284] New: [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr dani at danielbertalan dot dev
2022-01-29 21:40 ` [Bug c++/104284] " pinskia at gcc dot gnu.org
2022-01-29 21:41 ` pinskia at gcc dot gnu.org
2022-01-31  9:11 ` [Bug c++/104284] [9/10/11/12 Regression] ICE: unexpected expression '<anonymous>' of kind implicit_conv_expr since r9-6073-ge8b3c1bc3ba22dcf marxin at gcc dot gnu.org
2022-03-09 13:20 ` rguenth at gcc dot gnu.org
2022-03-10 17:55 ` mpolacek at gcc dot gnu.org
2022-03-24 22:44 ` cvs-commit at gcc dot gnu.org
2022-03-24 22:44 ` [Bug c++/104284] [9/10/11 " mpolacek at gcc dot gnu.org
2022-03-29  1:45 ` cvs-commit at gcc dot gnu.org
2022-03-29  1:48 ` [Bug c++/104284] [9/10 " mpolacek at gcc dot gnu.org
2024-03-26 17:18 ` 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).