public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/105604] New: [10/11/12 Regression] ICE: in tree_to_shwi, at tree.cc:6369
@ 2022-05-14 20:20 slyfox at gcc dot gnu.org
  2022-05-14 20:26 ` [Bug middle-end/105604] [10/11/12 Regression] ICE: in tree_to_shwi with vla in struct and sprintf pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: slyfox at gcc dot gnu.org @ 2022-05-14 20:20 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105604
           Summary: [10/11/12 Regression] ICE: in tree_to_shwi, at
                    tree.cc:6369
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at gcc dot gnu.org
  Target Milestone: ---

Originally reported by cpu in https://bugs.gentoo.org/844091. Here is my
attempt at minimizing it:

//$ cat main.c
struct {
  long users;
  long size;
  char *data;
} * main_trans;
void *main___trans_tmp_1;
int sprintf(char *, char *, ...);
int main() {
  int users = 0;
  struct {
    long users;
    long size;
    char *data;
    int links[users];
    char buf[];
  } *trans = trans;
  trans->data = trans->buf;
  main___trans_tmp_1 = trans;
  main_trans = main___trans_tmp_1;
  sprintf(main_trans->data, "test");
}


$ /tmp/gb/gcc/xgcc -B/tmp/gb/gcc -c -Wall -O2 -pipe -fomit-frame-pointer main.c
during GIMPLE pass: strlen
main.c: In function ‘main’:
main.c:8:5: internal compiler error: in tree_to_shwi, at tree.cc:6369
    8 | int main() {
      |     ^~~~
0x1116ade tree_to_shwi(tree_node const*)
        gcc/tree.cc:6369
0x1116b36 int_byte_position(tree_node const*)
        gcc/tree.cc:3616
0x1cd1ce8 get_origin_and_offset_r
        gcc/gimple-ssa-sprintf.cc:2354
0x1cd1845 get_origin_and_offset_r
        gcc/gimple-ssa-sprintf.cc:2307
0x1cd1f29 get_origin_and_offset_r
        gcc/gimple-ssa-sprintf.cc:2370
0x1cd64ce get_origin_and_offset
        gcc/gimple-ssa-sprintf.cc:2427
0x1cd64ce handle_printf_call(gimple_stmt_iterator*, pointer_query&)
        gcc/gimple-ssa-sprintf.cc:4703
0x103ff10 strlen_pass::check_and_optimize_call(bool*)
        gcc/tree-ssa-strlen.cc:5461
0x103ffb3 strlen_pass::check_and_optimize_stmt(bool*)
        gcc/tree-ssa-strlen.cc:5665
0x1040326 strlen_pass::before_dom_children(basic_block_def*)
        gcc/tree-ssa-strlen.cc:5849
0x1c5d56b dom_walker::walk(basic_block_def*)
        gcc/domwalk.cc:309
0x10409cf printf_strlen_execute
        gcc/tree-ssa-strlen.cc:5908
0x1040c58 execute
        gcc/tree-ssa-strlen.cc:6007

I seem to be able to reproduce ICE on: 10.3.0, 11.3.0, 12.1.0.
This does not ICE: 9.3.0

$ /tmp/gb/gcc/xgcc -B/tmp/gb/gcc -v

Reading specs from /tmp/gb/gcc/specs
COLLECT_GCC=/tmp/gb/gcc/xgcc
COLLECT_LTO_WRAPPER=/tmp/gb/gcc/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/slyfox/dev/git/gcc/configure --disable-multilib
--disable-bootstrap
--with-native-system-header-dir=/<<NIX>>/glibc-2.34-115-dev/include
--prefix=/tmp/gb/__td__ CFLAGS='-O1 -ggdb3' CXXFLAGS='-O1 -ggdb3' LDFLAGS='-O1
-ggdb3'
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.0 20220514 (experimental) (GCC)

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

* [Bug middle-end/105604] [10/11/12 Regression] ICE: in tree_to_shwi with vla in struct and sprintf
  2022-05-14 20:20 [Bug middle-end/105604] New: [10/11/12 Regression] ICE: in tree_to_shwi, at tree.cc:6369 slyfox at gcc dot gnu.org
@ 2022-05-14 20:26 ` pinskia at gcc dot gnu.org
  2022-05-16  7:09 ` [Bug middle-end/105604] [10/11/12/13 " marxin at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-14 20:26 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic,
                   |                            |ice-on-valid-code
   Target Milestone|---                         |10.4
            Summary|[10/11/12 Regression] ICE:  |[10/11/12 Regression] ICE:
                   |in tree_to_shwi, at         |in tree_to_shwi with vla in
                   |tree.cc:6369                |struct and sprintf

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Feels like someone forgot to check if the type had a non constant size/offsets.

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

* [Bug middle-end/105604] [10/11/12/13 Regression] ICE: in tree_to_shwi with vla in struct and sprintf
  2022-05-14 20:20 [Bug middle-end/105604] New: [10/11/12 Regression] ICE: in tree_to_shwi, at tree.cc:6369 slyfox at gcc dot gnu.org
  2022-05-14 20:26 ` [Bug middle-end/105604] [10/11/12 Regression] ICE: in tree_to_shwi with vla in struct and sprintf pinskia at gcc dot gnu.org
@ 2022-05-16  7:09 ` marxin at gcc dot gnu.org
  2022-05-16  7:56 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-05-16  7:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-05-16
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |msebor at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r10-4571-g937a86b49e4ed8ef.

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

* [Bug middle-end/105604] [10/11/12/13 Regression] ICE: in tree_to_shwi with vla in struct and sprintf
  2022-05-14 20:20 [Bug middle-end/105604] New: [10/11/12 Regression] ICE: in tree_to_shwi, at tree.cc:6369 slyfox at gcc dot gnu.org
  2022-05-14 20:26 ` [Bug middle-end/105604] [10/11/12 Regression] ICE: in tree_to_shwi with vla in struct and sprintf pinskia at gcc dot gnu.org
  2022-05-16  7:09 ` [Bug middle-end/105604] [10/11/12/13 " marxin at gcc dot gnu.org
@ 2022-05-16  7:56 ` rguenth at gcc dot gnu.org
  2022-05-24 22:20 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-16  7:56 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Not only that.

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

* [Bug middle-end/105604] [10/11/12/13 Regression] ICE: in tree_to_shwi with vla in struct and sprintf
  2022-05-14 20:20 [Bug middle-end/105604] New: [10/11/12 Regression] ICE: in tree_to_shwi, at tree.cc:6369 slyfox at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-05-16  7:56 ` rguenth at gcc dot gnu.org
@ 2022-05-24 22:20 ` cvs-commit at gcc dot gnu.org
  2022-05-24 22:22 ` [Bug middle-end/105604] [10/11/12 " msebor at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-24 22:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:10d1986aee47c592f903527bb68546efc557735d

commit r13-750-g10d1986aee47c592f903527bb68546efc557735d
Author: Martin Sebor <msebor@redhat.com>
Date:   Tue May 24 16:01:12 2022 -0600

    PR middle-end/105604 - ICE: in tree_to_shwi with vla in struct and sprintf

    gcc/ChangeLog:

            PR middle-end/105604
            * gimple-ssa-sprintf.cc (set_aggregate_size_and_offset): Add
comments.
            (get_origin_and_offset_r): Remove null handling.  Handle variable
array
            sizes.
            (get_origin_and_offset): Handle null argument here.  Simplify.
            (alias_offset): Update comment.
            * pointer-query.cc (field_at_offset): Update comment.  Handle
members
            of variable-length types.

    gcc/testsuite/ChangeLog:

            PR middle-end/105604
            * gcc.dg/Wrestrict-24.c: New test.
            * gcc.dg/Wrestrict-25.c: New test.
            * gcc.dg/Wrestrict-26.c: New test.

    Co-authored-by: Richard Biener <rguenther@suse.de>

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

* [Bug middle-end/105604] [10/11/12 Regression] ICE: in tree_to_shwi with vla in struct and sprintf
  2022-05-14 20:20 [Bug middle-end/105604] New: [10/11/12 Regression] ICE: in tree_to_shwi, at tree.cc:6369 slyfox at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-05-24 22:20 ` cvs-commit at gcc dot gnu.org
@ 2022-05-24 22:22 ` msebor at gcc dot gnu.org
  2022-06-02  9:39 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: msebor at gcc dot gnu.org @ 2022-05-24 22:22 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11/12/13 Regression]    |[10/11/12 Regression] ICE:
                   |ICE: in tree_to_shwi with   |in tree_to_shwi with vla in
                   |vla in struct and sprintf   |struct and sprintf
             Blocks|                            |84774

--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
Fixed on trunk.  The changes should be safe to backport after some time.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84774
[Bug 84774] [meta-bug] bogus/missing -Wrestrict

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

* [Bug middle-end/105604] [10/11/12 Regression] ICE: in tree_to_shwi with vla in struct and sprintf
  2022-05-14 20:20 [Bug middle-end/105604] New: [10/11/12 Regression] ICE: in tree_to_shwi, at tree.cc:6369 slyfox at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-05-24 22:22 ` [Bug middle-end/105604] [10/11/12 " msebor at gcc dot gnu.org
@ 2022-06-02  9:39 ` cvs-commit at gcc dot gnu.org
  2022-06-15  8:02 ` [Bug middle-end/105604] [10/11 " rguenth 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-06-02  9:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:740771a620f661800b99dfc039b8896e2ddb9265

commit r12-8450-g740771a620f661800b99dfc039b8896e2ddb9265
Author: Martin Sebor <msebor@redhat.com>
Date:   Tue May 24 16:01:12 2022 -0600

    PR middle-end/105604 - ICE: in tree_to_shwi with vla in struct and sprintf

    gcc/ChangeLog:

            PR middle-end/105604
            * gimple-ssa-sprintf.cc (set_aggregate_size_and_offset): Add
comments.
            (get_origin_and_offset_r): Remove null handling.  Handle variable
array
            sizes.
            (get_origin_and_offset): Handle null argument here.  Simplify.
            (alias_offset): Update comment.
            * pointer-query.cc (field_at_offset): Update comment.  Handle
members
            of variable-length types.

    gcc/testsuite/ChangeLog:

            PR middle-end/105604
            * gcc.dg/Wrestrict-24.c: New test.
            * gcc.dg/Wrestrict-25.c: New test.
            * gcc.dg/Wrestrict-26.c: New test.

    Co-authored-by: Richard Biener <rguenther@suse.de>
    (cherry picked from commit 10d1986aee47c592f903527bb68546efc557735d)

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

* [Bug middle-end/105604] [10/11 Regression] ICE: in tree_to_shwi with vla in struct and sprintf
  2022-05-14 20:20 [Bug middle-end/105604] New: [10/11/12 Regression] ICE: in tree_to_shwi, at tree.cc:6369 slyfox at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2022-06-02  9:39 ` cvs-commit at gcc dot gnu.org
@ 2022-06-15  8:02 ` rguenth at gcc dot gnu.org
  2022-06-28 10:49 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-06-15  8:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|rguenth at gcc dot gnu.org         |unassigned at gcc dot gnu.org
             Status|ASSIGNED                    |NEW
            Version|12.0                        |11.2.1

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Originally (gentoo) reported against 11.2, but the fix doesn't cherry-pick
nicely.

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

* [Bug middle-end/105604] [10/11 Regression] ICE: in tree_to_shwi with vla in struct and sprintf
  2022-05-14 20:20 [Bug middle-end/105604] New: [10/11/12 Regression] ICE: in tree_to_shwi, at tree.cc:6369 slyfox at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2022-06-15  8:02 ` [Bug middle-end/105604] [10/11 " rguenth at gcc dot gnu.org
@ 2022-06-28 10:49 ` jakub at gcc dot gnu.org
  2022-07-19 11:39 ` rguenth at gcc dot gnu.org
  2023-07-07 10:43 ` [Bug middle-end/105604] [11 " rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.4                        |10.5

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

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

* [Bug middle-end/105604] [10/11 Regression] ICE: in tree_to_shwi with vla in struct and sprintf
  2022-05-14 20:20 [Bug middle-end/105604] New: [10/11/12 Regression] ICE: in tree_to_shwi, at tree.cc:6369 slyfox at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2022-06-28 10:49 ` jakub at gcc dot gnu.org
@ 2022-07-19 11:39 ` rguenth at gcc dot gnu.org
  2023-07-07 10:43 ` [Bug middle-end/105604] [11 " rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-07-19 11:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105604
Bug 105604 depends on bug 105969, which changed state.

Bug 105969 Summary: [12 Regression] ICE in Floating point exception since r13-750-g10d1986aee47c5
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105969

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

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

* [Bug middle-end/105604] [11 Regression] ICE: in tree_to_shwi with vla in struct and sprintf
  2022-05-14 20:20 [Bug middle-end/105604] New: [10/11/12 Regression] ICE: in tree_to_shwi, at tree.cc:6369 slyfox at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2022-07-19 11:39 ` rguenth at gcc dot gnu.org
@ 2023-07-07 10:43 ` rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:43 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.5                        |11.5

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.

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

end of thread, other threads:[~2023-07-07 10:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-14 20:20 [Bug middle-end/105604] New: [10/11/12 Regression] ICE: in tree_to_shwi, at tree.cc:6369 slyfox at gcc dot gnu.org
2022-05-14 20:26 ` [Bug middle-end/105604] [10/11/12 Regression] ICE: in tree_to_shwi with vla in struct and sprintf pinskia at gcc dot gnu.org
2022-05-16  7:09 ` [Bug middle-end/105604] [10/11/12/13 " marxin at gcc dot gnu.org
2022-05-16  7:56 ` rguenth at gcc dot gnu.org
2022-05-24 22:20 ` cvs-commit at gcc dot gnu.org
2022-05-24 22:22 ` [Bug middle-end/105604] [10/11/12 " msebor at gcc dot gnu.org
2022-06-02  9:39 ` cvs-commit at gcc dot gnu.org
2022-06-15  8:02 ` [Bug middle-end/105604] [10/11 " rguenth at gcc dot gnu.org
2022-06-28 10:49 ` jakub at gcc dot gnu.org
2022-07-19 11:39 ` rguenth at gcc dot gnu.org
2023-07-07 10:43 ` [Bug middle-end/105604] [11 " 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).