public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103114] New: [12 Regression] ICE in build_complex, at tree.c:2470
@ 2021-11-07  5:48 asolokha at gmx dot com
  2021-11-07  6:45 ` [Bug c++/103114] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: asolokha at gmx dot com @ 2021-11-07  5:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103114
           Summary: [12 Regression] ICE in build_complex, at tree.c:2470
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asolokha at gmx dot com
  Target Milestone: ---

g++-12.0.0-alpha20211031 snapshot (g:ca84f39399fda80c770306465276ffd66d3766ed)
ICEs when compiling the following testcase, reduced from
gcc/testsuite/gcc.c-torture/execute/complex-7.c, w/ -frounding-math:

_Complex double d5 = 10.1i;

% g++-12.0.0 -frounding-math -c yiyfoum8.c
yiyfoum8.c:1:22: internal compiler error: in build_complex, at tree.c:2470
    1 | _Complex double d5 = 10.1i;
      |                      ^~~~~
0x86be9c build_complex(tree_node*, tree_node*, tree_node*)
       
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211031/work/gcc-12-20211031/gcc/tree.c:2470
0xaa1373 cp_parser_userdef_numeric_literal
       
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211031/work/gcc-12-20211031/gcc/cp/parser.c:4807
0xabd70e cp_parser_postfix_expression
       
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211031/work/gcc-12-20211031/gcc/cp/parser.c:7581
0xaa50ca cp_parser_binary_expression
       
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211031/work/gcc-12-20211031/gcc/cp/parser.c:9911
0xaa5c7a cp_parser_assignment_expression
       
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211031/work/gcc-12-20211031/gcc/cp/parser.c:10215
0xaa7fcd cp_parser_constant_expression
       
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211031/work/gcc-12-20211031/gcc/cp/parser.c:10518
0xaa80f1 cp_parser_initializer_clause
       
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211031/work/gcc-12-20211031/gcc/cp/parser.c:25070
0xaabadc cp_parser_initializer
       
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211031/work/gcc-12-20211031/gcc/cp/parser.c:25010
0xadbb3b cp_parser_init_declarator
       
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211031/work/gcc-12-20211031/gcc/cp/parser.c:22631
0xab5d49 cp_parser_simple_declaration
       
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211031/work/gcc-12-20211031/gcc/cp/parser.c:15156
0xae758b cp_parser_declaration
       
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211031/work/gcc-12-20211031/gcc/cp/parser.c:14842
0xae806a cp_parser_toplevel_declaration
       
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211031/work/gcc-12-20211031/gcc/cp/parser.c:14863
0xae806a cp_parser_translation_unit
       
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211031/work/gcc-12-20211031/gcc/cp/parser.c:4987
0xae806a c_parse_file()
       
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211031/work/gcc-12-20211031/gcc/cp/parser.c:47840
0xc1b7ed c_common_parse_file()
       
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211031/work/gcc-12-20211031/gcc/c-family/c-opts.c:1237

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

* [Bug c++/103114] [12 Regression] ICE in build_complex, at tree.c:2470
  2021-11-07  5:48 [Bug c++/103114] New: [12 Regression] ICE in build_complex, at tree.c:2470 asolokha at gmx dot com
@ 2021-11-07  6:45 ` pinskia at gcc dot gnu.org
  2021-11-07  6:46 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-07  6:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0

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

* [Bug c++/103114] [12 Regression] ICE in build_complex, at tree.c:2470
  2021-11-07  5:48 [Bug c++/103114] New: [12 Regression] ICE in build_complex, at tree.c:2470 asolokha at gmx dot com
  2021-11-07  6:45 ` [Bug c++/103114] " pinskia at gcc dot gnu.org
@ 2021-11-07  6:46 ` pinskia at gcc dot gnu.org
  2021-11-08  8:36 ` [Bug c++/103114] [12 Regression] ICE in build_complex, at tree.c:2470 since r12-4764-ga84b9d5373c7e67f marxin at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-07  6:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |needs-bisection
   Last reconfirmed|                            |2021-11-07
      Known to work|                            |11.2.0
      Known to fail|                            |12.0
     Ever confirmed|0                           |1

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

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

* [Bug c++/103114] [12 Regression] ICE in build_complex, at tree.c:2470 since r12-4764-ga84b9d5373c7e67f
  2021-11-07  5:48 [Bug c++/103114] New: [12 Regression] ICE in build_complex, at tree.c:2470 asolokha at gmx dot com
  2021-11-07  6:45 ` [Bug c++/103114] " pinskia at gcc dot gnu.org
  2021-11-07  6:46 ` pinskia at gcc dot gnu.org
@ 2021-11-08  8:36 ` marxin at gcc dot gnu.org
  2021-11-08  9:08 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-08  8:36 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[12 Regression] ICE in      |[12 Regression] ICE in
                   |build_complex, at           |build_complex, at
                   |tree.c:2470                 |tree.c:2470 since
                   |                            |r12-4764-ga84b9d5373c7e67f
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org
           Keywords|needs-bisection             |

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r12-4764-ga84b9d5373c7e67f.

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

* [Bug c++/103114] [12 Regression] ICE in build_complex, at tree.c:2470 since r12-4764-ga84b9d5373c7e67f
  2021-11-07  5:48 [Bug c++/103114] New: [12 Regression] ICE in build_complex, at tree.c:2470 asolokha at gmx dot com
                   ` (2 preceding siblings ...)
  2021-11-08  8:36 ` [Bug c++/103114] [12 Regression] ICE in build_complex, at tree.c:2470 since r12-4764-ga84b9d5373c7e67f marxin at gcc dot gnu.org
@ 2021-11-08  9:08 ` jakub at gcc dot gnu.org
  2021-11-08  9:13 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-11-08  9:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The FE should check if the second fold_convert folds into constant (the first
one for 0 will always succeed) and build_complex only if it is, otherwise build
a COMPLEX_EXPR.

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

* [Bug c++/103114] [12 Regression] ICE in build_complex, at tree.c:2470 since r12-4764-ga84b9d5373c7e67f
  2021-11-07  5:48 [Bug c++/103114] New: [12 Regression] ICE in build_complex, at tree.c:2470 asolokha at gmx dot com
                   ` (3 preceding siblings ...)
  2021-11-08  9:08 ` jakub at gcc dot gnu.org
@ 2021-11-08  9:13 ` rguenth at gcc dot gnu.org
  2021-11-08  9:19 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-11-08  9:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Or always build+fold a COMPLEX_EXPR.

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

* [Bug c++/103114] [12 Regression] ICE in build_complex, at tree.c:2470 since r12-4764-ga84b9d5373c7e67f
  2021-11-07  5:48 [Bug c++/103114] New: [12 Regression] ICE in build_complex, at tree.c:2470 asolokha at gmx dot com
                   ` (4 preceding siblings ...)
  2021-11-08  9:13 ` rguenth at gcc dot gnu.org
@ 2021-11-08  9:19 ` jakub at gcc dot gnu.org
  2021-11-08  9:53 ` rguenther at suse dot de
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-11-08  9:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
--- gcc/cp/parser.c.jj  2021-10-28 20:07:48.571193189 +0200
+++ gcc/cp/parser.c     2021-11-08 10:18:02.042896144 +0100
@@ -4804,9 +4804,9 @@ cp_parser_userdef_numeric_literal (cp_pa
       else /* if (id_equal (suffix_id, "il")) */
        type = long_double_type_node;

-      value = build_complex (build_complex_type (type),
-                            fold_convert (type, integer_zero_node),
-                            fold_convert (type, value));
+      value = fold_build2 (COMPLEX_EXPR, build_complex_type (type),
+                          fold_convert (type, integer_zero_node),
+                          fold_convert (type, value));
     }

   if (cp_parser_uncommitted_to_tentative_parse_p (parser))
does that indeed, for the usual case it will do fold_binary_loc -> const_binop
-> build_complex.

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

* [Bug c++/103114] [12 Regression] ICE in build_complex, at tree.c:2470 since r12-4764-ga84b9d5373c7e67f
  2021-11-07  5:48 [Bug c++/103114] New: [12 Regression] ICE in build_complex, at tree.c:2470 asolokha at gmx dot com
                   ` (5 preceding siblings ...)
  2021-11-08  9:19 ` jakub at gcc dot gnu.org
@ 2021-11-08  9:53 ` rguenther at suse dot de
  2021-11-09 14:30 ` cvs-commit at gcc dot gnu.org
  2021-11-09 14:30 ` jakub at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenther at suse dot de @ 2021-11-08  9:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from rguenther at suse dot de <rguenther at suse dot de> ---
On Mon, 8 Nov 2021, jakub at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103114
> 
> --- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> --- gcc/cp/parser.c.jj  2021-10-28 20:07:48.571193189 +0200
> +++ gcc/cp/parser.c     2021-11-08 10:18:02.042896144 +0100
> @@ -4804,9 +4804,9 @@ cp_parser_userdef_numeric_literal (cp_pa
>        else /* if (id_equal (suffix_id, "il")) */
>         type = long_double_type_node;
> 
> -      value = build_complex (build_complex_type (type),
> -                            fold_convert (type, integer_zero_node),
> -                            fold_convert (type, value));
> +      value = fold_build2 (COMPLEX_EXPR, build_complex_type (type),
> +                          fold_convert (type, integer_zero_node),

build_zero_cost (type) should be cheaper

> +                          fold_convert (type, value));
>      }
> 
>    if (cp_parser_uncommitted_to_tentative_parse_p (parser))
> does that indeed, for the usual case it will do fold_binary_loc -> const_binop
> -> build_complex.
> 
>

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

* [Bug c++/103114] [12 Regression] ICE in build_complex, at tree.c:2470 since r12-4764-ga84b9d5373c7e67f
  2021-11-07  5:48 [Bug c++/103114] New: [12 Regression] ICE in build_complex, at tree.c:2470 asolokha at gmx dot com
                   ` (6 preceding siblings ...)
  2021-11-08  9:53 ` rguenther at suse dot de
@ 2021-11-09 14:30 ` cvs-commit at gcc dot gnu.org
  2021-11-09 14:30 ` jakub at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-09 14:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:0318df0ae63e47f6b2f30e96205d00dcb3696538

commit r12-5054-g0318df0ae63e47f6b2f30e96205d00dcb3696538
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Nov 9 15:29:36 2021 +0100

    c++: Fix ICE on complex constant with -frounding-math [PR103114]

    The FE uses build_complex which assumes that fold_convert will fold
    value to a constant.  With -frounding-math that isn't guaranteed though.
    So, the patch instead fold_build2s COMPLEX_EXPR, which will result
    in build_complex if both arguments are constants, and otherwise
    will build COMPLEX_EXPR.
    build_zero_cst is an optimization for fold_convert (type,
integer_zero_node).

    2021-11-09  Jakub Jelinek  <jakub@redhat.com>

            PR c++/103114
            * parser.c (cp_parser_userdef_numeric_literal): Use fold_build2
            with COMPLEX_EXPR arg instead of build_complex, use build_zero_cst
            instead of fold_convert from integer_zero_node.

            * g++.dg/ext/complex10.C: New test.

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

* [Bug c++/103114] [12 Regression] ICE in build_complex, at tree.c:2470 since r12-4764-ga84b9d5373c7e67f
  2021-11-07  5:48 [Bug c++/103114] New: [12 Regression] ICE in build_complex, at tree.c:2470 asolokha at gmx dot com
                   ` (7 preceding siblings ...)
  2021-11-09 14:30 ` cvs-commit at gcc dot gnu.org
@ 2021-11-09 14:30 ` jakub at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-11-09 14:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed now.

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

end of thread, other threads:[~2021-11-09 14:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-07  5:48 [Bug c++/103114] New: [12 Regression] ICE in build_complex, at tree.c:2470 asolokha at gmx dot com
2021-11-07  6:45 ` [Bug c++/103114] " pinskia at gcc dot gnu.org
2021-11-07  6:46 ` pinskia at gcc dot gnu.org
2021-11-08  8:36 ` [Bug c++/103114] [12 Regression] ICE in build_complex, at tree.c:2470 since r12-4764-ga84b9d5373c7e67f marxin at gcc dot gnu.org
2021-11-08  9:08 ` jakub at gcc dot gnu.org
2021-11-08  9:13 ` rguenth at gcc dot gnu.org
2021-11-08  9:19 ` jakub at gcc dot gnu.org
2021-11-08  9:53 ` rguenther at suse dot de
2021-11-09 14:30 ` cvs-commit at gcc dot gnu.org
2021-11-09 14:30 ` jakub 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).