public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111059] New: ICE: in gimplify_expr, at gimplify.cc:17253
@ 2023-08-18  7:51 iamanonymous.cs at gmail dot com
  2023-08-18  7:56 ` [Bug c/111059] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: iamanonymous.cs at gmail dot com @ 2023-08-18  7:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111059
           Summary: ICE: in gimplify_expr, at gimplify.cc:17253
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iamanonymous.cs at gmail dot com
  Target Milestone: ---

Created attachment 55752
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55752&action=edit
The program.c mentioned in description.

*******************************************************************************
OS and Platform:
$ uname -a:
Linux ubuntu 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023
x86_64 x86_64 x86_64 GNU/Linux
*******************************************************************************
gcc version:
$ gcc -v
Using built-in specs.
COLLECT_GCC=/root/gcc_set/new_gcc/bin/gcc
COLLECT_LTO_WRAPPER=/root/gcc_set/new_gcc/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/root/gcc_set/new_gcc
--with-gmp=/root/build_essential --with-mpfr=/root/build_essential
--with-mpc=/root/build_essential --enable-languages=c,c++ --disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230719 (experimental) (GCC)

git version:85da0b40538fb0d17d89de1e7905984668e3dfef
*******************************************************************************
Program:
The program was attached as program.c
*******************************************************************************
Command Lines:
$ gcc program.c -o program
program.c: In function ‘test’:
program.c:188:176: warning: left shift count is negative
[-Wshift-count-negative]
  188 |                                 arr_33 [i_0] [i_1] [i_2] = ((/*
implicit */_Bool) ((((/* implicit */_Bool) (short)1139)) ? ((((~(((/* implicit
*/int) (unsigned short)9080)))) << (((/* implicit */int) (signed char)-23)))) :
(-1376368525)));
      |                                                                        
                                                                               
                       ^~
program.c:188:176: internal compiler error: in gimplify_expr, at
gimplify.cc:17253
0x7773da gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gcc/gimplify.cc:17253
0xc84dba gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gcc/gimplify.cc:17223
0xc97dc7 gimplify_modify_expr
        ../../gcc/gcc/gimplify.cc:6173
0xc84fa6 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gcc/gimplify.cc:16441
0xc87a16 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gcc/gimplify.cc:7246
0xc86380 gimplify_statement_list
        ../../gcc/gcc/gimplify.cc:2019
0xc86380 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gcc/gimplify.cc:16886
0xc87a16 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gcc/gimplify.cc:7246
0xc96ad9 gimplify_cond_expr
        ../../gcc/gcc/gimplify.cc:4562
0xc8575c gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gcc/gimplify.cc:16398
0xc87a16 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gcc/gimplify.cc:7246
0xc86380 gimplify_statement_list
        ../../gcc/gcc/gimplify.cc:2019
0xc86380 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gcc/gimplify.cc:16886
0xc87a16 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gcc/gimplify.cc:7246
0xc86380 gimplify_statement_list
        ../../gcc/gcc/gimplify.cc:2019
0xc86380 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gcc/gimplify.cc:16886
0xc87a16 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gcc/gimplify.cc:7246
0xc88146 gimplify_bind_expr
        ../../gcc/gcc/gimplify.cc:1430
0xc8525e gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gcc/gimplify.cc:16642
0xc87a16 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gcc/gimplify.cc:7246
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

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

* [Bug c/111059] ICE: in gimplify_expr, at gimplify.cc:17253
  2023-08-18  7:51 [Bug c/111059] New: ICE: in gimplify_expr, at gimplify.cc:17253 iamanonymous.cs at gmail dot com
@ 2023-08-18  7:56 ` pinskia at gcc dot gnu.org
  2023-08-18  8:09 ` [Bug c/111059] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-18  7:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(gdb) p debug_tree(*expr_p)
 <c_maybe_const_expr 0x7ffff77f4078
    type <integer_type 0x7ffff76215e8 int sizes-gimplified public SI
        size <integer_cst 0x7ffff7625000 constant 32>
        unit-size <integer_cst 0x7ffff7625018 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff76215e8 precision:32 min <integer_cst 0x7ffff7602fa8 -2147483648> max
<integer_cst 0x7ffff7602fc0 2147483647>
        pointer_to_this <pointer_type 0x7ffff7629b28>>
    readonly
    arg:1 <lshift_expr 0x7ffff77f4000 type <integer_type 0x7ffff76215e8 int>
        readonly constant
        arg:0 <integer_cst 0x7ffff77f1510 constant -9081>
        arg:1 <integer_cst 0x7ffff77f1528 constant -23>
        t.c:183:176 start: t.c:183:176 finish: t.c:183:177>
    t.c:183:176 start: t.c:183:176 finish: t.c:183:177>

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

* [Bug c/111059] [11/12/13/14 Regression] ICE: in gimplify_expr, at gimplify.cc:17253
  2023-08-18  7:51 [Bug c/111059] New: ICE: in gimplify_expr, at gimplify.cc:17253 iamanonymous.cs at gmail dot com
  2023-08-18  7:56 ` [Bug c/111059] " pinskia at gcc dot gnu.org
@ 2023-08-18  8:09 ` pinskia at gcc dot gnu.org
  2023-08-18  8:16 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-18  8:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-08-18
      Known to work|                            |10.5.0
            Summary|ICE: in gimplify_expr, at   |[11/12/13/14 Regression]
                   |gimplify.cc:17253           |ICE: in gimplify_expr, at
                   |                            |gimplify.cc:17253
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Keywords|                            |ice-on-valid-code
   Target Milestone|---                         |11.5

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. Reduced testcase:
```
void f() {
  (_Bool) (1 << -1);
}
```

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

* [Bug c/111059] [11/12/13/14 Regression] ICE: in gimplify_expr, at gimplify.cc:17253
  2023-08-18  7:51 [Bug c/111059] New: ICE: in gimplify_expr, at gimplify.cc:17253 iamanonymous.cs at gmail dot com
  2023-08-18  7:56 ` [Bug c/111059] " pinskia at gcc dot gnu.org
  2023-08-18  8:09 ` [Bug c/111059] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
@ 2023-08-18  8:16 ` pinskia at gcc dot gnu.org
  2023-08-28 14:48 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-18  8:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=96929

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I have a feeling this was caused by r11-5271-g4866b2f5db117f9e89f8 and the
similar handling of negative shifts need to be added to the C front-end as the
C++ front-end too.

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

* [Bug c/111059] [11/12/13/14 Regression] ICE: in gimplify_expr, at gimplify.cc:17253
  2023-08-18  7:51 [Bug c/111059] New: ICE: in gimplify_expr, at gimplify.cc:17253 iamanonymous.cs at gmail dot com
                   ` (2 preceding siblings ...)
  2023-08-18  8:16 ` pinskia at gcc dot gnu.org
@ 2023-08-28 14:48 ` jakub at gcc dot gnu.org
  2024-01-30 22:16 ` jsm28 at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-08-28 14:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
void f() {
  (_Bool) (0 / 0);
}
ICEs too, so I think the problem is elsewhere.

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

* [Bug c/111059] [11/12/13/14 Regression] ICE: in gimplify_expr, at gimplify.cc:17253
  2023-08-18  7:51 [Bug c/111059] New: ICE: in gimplify_expr, at gimplify.cc:17253 iamanonymous.cs at gmail dot com
                   ` (3 preceding siblings ...)
  2023-08-28 14:48 ` jakub at gcc dot gnu.org
@ 2024-01-30 22:16 ` jsm28 at gcc dot gnu.org
  2024-01-31  1:25 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2024-01-30 22:16 UTC (permalink / raw)
  To: gcc-bugs

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

Joseph S. Myers <jsm28 at gcc dot gnu.org> changed:

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

--- Comment #5 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
Testing a patch.

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

* [Bug c/111059] [11/12/13/14 Regression] ICE: in gimplify_expr, at gimplify.cc:17253
  2023-08-18  7:51 [Bug c/111059] New: ICE: in gimplify_expr, at gimplify.cc:17253 iamanonymous.cs at gmail dot com
                   ` (4 preceding siblings ...)
  2024-01-30 22:16 ` jsm28 at gcc dot gnu.org
@ 2024-01-31  1:25 ` cvs-commit at gcc dot gnu.org
  2024-01-31  1:28 ` [Bug c/111059] [11/12/13 " jsm28 at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-31  1:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Joseph Myers <jsm28@gcc.gnu.org>:

https://gcc.gnu.org/g:35de88e2ed0aa78f6e3306c8560cd6bb15ce0ffe

commit r14-8641-g35de88e2ed0aa78f6e3306c8560cd6bb15ce0ffe
Author: Joseph Myers <josmyers@redhat.com>
Date:   Wed Jan 31 01:24:21 2024 +0000

    c: Fix ICEs casting expressions with integer constant operands to bool
[PR111059, PR111911]

    C front-end bugs 111059 and 111911 both report ICEs with conversions
    to boolean of expressions with integer constant operands that can
    appear in an integer constant expression as long as they are not
    evaluated (such as division by zero).

    The issue is a nested C_MAYBE_CONST_EXPR, with the inner one generated
    in build_binary_op to indicate that a subexpression has been fully
    folded and should not be folded again, and the outer one in
    build_c_cast to indicate that the expression has integer constant
    operands.  To avoid the inner one from build_binary_op,
    c_objc_common_truthvalue_conversion should be given an argument
    properly marked as having integer constant operands rather than that
    information having been removed by the caller - but because c_convert
    would then also wrap a C_MAYBE_CONST_EXPR with a NOP_EXPR converting
    to boolean, it seems most convenient to have
    c_objc_common_truthvalue_conversion produce the NE_EXPR directly in
    the desired type (boolean in this case), before generating any
    C_MAYBE_CONST_EXPR there, rather than it always producing a comparison
    in integer_type_node and doing a conversion to boolean in the caller.

    The same issue as in those PRs also applies for conversion to enums
    with a boolean fixed underlying type; that case is also fixed and
    tests added for it.  Note that not all the tests added failed before
    the patch (in particular, the issue was specific to casts and did not
    apply for implicit conversions, but some tests of those are added as
    well).

    Bootstrapped with no regressions for x86_64-pc-linux-gnu.

            PR c/111059
            PR c/111911

    gcc/c/
            * c-tree.h (c_objc_common_truthvalue_conversion): Add third
            argument.
            * c-convert.cc (c_convert): For conversions to boolean, pass third
            argument to c_objc_common_truthvalue_conversion rather than
            converting here.
            * c-typeck.cc (build_c_cast): Ensure arguments with integer
            operands are marked as such for conversion to boolean.
            (c_objc_common_truthvalue_conversion): Add third argument TYPE.

    gcc/testsuite/
            * gcc.c-torture/compile/pr111059-1.c,
            gcc.c-torture/compile/pr111059-2.c,
            gcc.c-torture/compile/pr111059-3.c,
            gcc.c-torture/compile/pr111059-4.c,
            gcc.c-torture/compile/pr111059-5.c,
            gcc.c-torture/compile/pr111059-6.c,
            gcc.c-torture/compile/pr111059-7.c,
            gcc.c-torture/compile/pr111059-8.c,
            gcc.c-torture/compile/pr111059-9.c,
            gcc.c-torture/compile/pr111059-10.c,
            gcc.c-torture/compile/pr111059-11.c,
            gcc.c-torture/compile/pr111059-12.c,
            gcc.c-torture/compile/pr111911-1.c,
            gcc.c-torture/compile/pr111911-2.c: New tests.

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

* [Bug c/111059] [11/12/13 Regression] ICE: in gimplify_expr, at gimplify.cc:17253
  2023-08-18  7:51 [Bug c/111059] New: ICE: in gimplify_expr, at gimplify.cc:17253 iamanonymous.cs at gmail dot com
                   ` (5 preceding siblings ...)
  2024-01-31  1:25 ` cvs-commit at gcc dot gnu.org
@ 2024-01-31  1:28 ` jsm28 at gcc dot gnu.org
  2024-02-08  1:35 ` cvs-commit at gcc dot gnu.org
  2024-05-13 11:32 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2024-01-31  1:28 UTC (permalink / raw)
  To: gcc-bugs

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

Joseph S. Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11/12/13/14 Regression]    |[11/12/13 Regression] ICE:
                   |ICE: in gimplify_expr, at   |in gimplify_expr, at
                   |gimplify.cc:17253           |gimplify.cc:17253

--- Comment #7 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
Fixed so far for GCC 14.

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

* [Bug c/111059] [11/12/13 Regression] ICE: in gimplify_expr, at gimplify.cc:17253
  2023-08-18  7:51 [Bug c/111059] New: ICE: in gimplify_expr, at gimplify.cc:17253 iamanonymous.cs at gmail dot com
                   ` (6 preceding siblings ...)
  2024-01-31  1:28 ` [Bug c/111059] [11/12/13 " jsm28 at gcc dot gnu.org
@ 2024-02-08  1:35 ` cvs-commit at gcc dot gnu.org
  2024-05-13 11:32 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-08  1:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Joseph Myers <jsm28@gcc.gnu.org>:

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

commit r14-8874-gbfd72bb44eca83b0db2b0bab895f27a8a44247a2
Author: Joseph Myers <josmyers@redhat.com>
Date:   Thu Feb 8 01:34:09 2024 +0000

    c: Fix boolean conversion of floating constant as integer constant
expression [PR113776]

    My fix for bug 111059 and bug 111911 caused a conversion of a floating
    constant to boolean to wrongly no longer be considered an integer
    constant expression, because logic to insert a NOP_EXPR in
    c_objc_common_truthvalue_conversion for an argument not an integer
    constant expression itself now took place after rather than before the
    conversion to bool.  In the specific case of casting a floating
    constant to bool, the result is an integer constant expression even
    though the argument isn't (build_c_cast deals with ensuring that casts
    to integer type of anything of floating type more complicated than a
    single floating constant don't get wrongly treated as integer constant
    expressions even if they fold to constants), so fix the logic in
    c_objc_common_truthvalue_conversion to handle that special case.

    Bootstrapped with no regressions for x86_64-pc-linux-gnu.

            PR c/113776

    gcc/c
            * c-typeck.cc (c_objc_common_truthvalue_conversion): Return an
            integer constant expression for boolean conversion of floating
            constant.

    gcc/testsuite/
            * gcc.dg/pr113776-1.c, gcc.dg/pr113776-2.c, gcc.dg/pr113776-3.c,
            gcc.dg/pr113776-4.c: New tests.

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

* [Bug c/111059] [11/12/13 Regression] ICE: in gimplify_expr, at gimplify.cc:17253
  2023-08-18  7:51 [Bug c/111059] New: ICE: in gimplify_expr, at gimplify.cc:17253 iamanonymous.cs at gmail dot com
                   ` (7 preceding siblings ...)
  2024-02-08  1:35 ` cvs-commit at gcc dot gnu.org
@ 2024-05-13 11:32 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-13 11:32 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

end of thread, other threads:[~2024-05-13 11:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-18  7:51 [Bug c/111059] New: ICE: in gimplify_expr, at gimplify.cc:17253 iamanonymous.cs at gmail dot com
2023-08-18  7:56 ` [Bug c/111059] " pinskia at gcc dot gnu.org
2023-08-18  8:09 ` [Bug c/111059] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
2023-08-18  8:16 ` pinskia at gcc dot gnu.org
2023-08-28 14:48 ` jakub at gcc dot gnu.org
2024-01-30 22:16 ` jsm28 at gcc dot gnu.org
2024-01-31  1:25 ` cvs-commit at gcc dot gnu.org
2024-01-31  1:28 ` [Bug c/111059] [11/12/13 " jsm28 at gcc dot gnu.org
2024-02-08  1:35 ` cvs-commit at gcc dot gnu.org
2024-05-13 11:32 ` rguenth 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).