public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/115290] New: tree check fail in c_tree_printer, at c/c-objc-common.cc:330
@ 2024-05-30  7:50 dcb314 at hotmail dot com
  2024-05-30 14:50 ` [Bug c/115290] [12/13/14/15 Regression] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: dcb314 at hotmail dot com @ 2024-05-30  7:50 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115290
           Summary: tree check fail in c_tree_printer, at
                    c/c-objc-common.cc:330
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

For this C code:

$ more bug1029.c
typedef enum { SERVER_HELLO_DONE } message_type_t;
message_type_t handshakes[256][32], tls13_handshakes[256][32];
void main() { (0 ? tls13_handshakes : handshakes) == tls13_handshakes; }
$ 

compiled as follows:

$ ~/gcc/results/bin/gcc -c -Wall bug1029.c 

does this:

bug1029.c:3:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
    3 | void main() { (0 ? tls13_handshakes : handshakes) == tls13_handshakes;
}
      |      ^~~~
bug1029.c: In function ‘main’:
bug1029.c:3:51: warning: comparison between two arrays [-Warray-compare]
    3 | void main() { (0 ? tls13_handshakes : handshakes) == tls13_handshakes;
}
      |                                                   ^~

tree check: expected tree that contains ‘decl minimal’ structure, have
‘cond_exp
r’ in c_tree_printer, at c/c-objc-common.cc:330
    3 | void main() { (0 ? tls13_handshakes : handshakes) == tls13_handshakes;
}
      | ^~~~
0x81bb1e tree_contains_struct_check_failed(tree_node const*,
tree_node_structure
_enum, char const*, int, char const*)
        ../../trunk.20210101/gcc/tree.cc:9169
0x6e18a8 contains_struct_check(tree_node*, tree_node_structure_enum, char
const*
, int, char const*)
        ../../trunk.20210101/gcc/tree.h:3770
0x6e18a8 c_tree_printer
        ../../trunk.20210101/gcc/c/c-objc-common.cc:330

The bug first appeared sometime before git hash 28b508233a12c132.

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

* [Bug c/115290] [12/13/14/15 Regression] tree check fail in c_tree_printer, at c/c-objc-common.cc:330
  2024-05-30  7:50 [Bug c/115290] New: tree check fail in c_tree_printer, at c/c-objc-common.cc:330 dcb314 at hotmail dot com
@ 2024-05-30 14:50 ` pinskia at gcc dot gnu.org
  2024-05-31  6:45 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-30 14:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
            Summary|tree check fail in          |[12/13/14/15 Regression]
                   |c_tree_printer, at          |tree check fail in
                   |c/c-objc-common.cc:330      |c_tree_printer, at
                   |                            |c/c-objc-common.cc:330
           Keywords|                            |ice-on-valid-code
   Last reconfirmed|                            |2024-05-30
   Target Milestone|---                         |12.4
            Version|unknown                     |15.0
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
<source>:4:50: note: use '&\204[0] == &tls13_handshakes[0]' to compare the
addresses

I think it was introduced with r12-4148-g2dda00b734888d which also introduced
the warning. Since the diagnostic looks broken with release checking.


+       inform (location, "use %<&%D[0] %s &%D[0]%> to compare the addresses",
+               op0, op_symbol_code (code), op1);


%D here is expecting a decl but we have an expression.

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

* [Bug c/115290] [12/13/14/15 Regression] tree check fail in c_tree_printer, at c/c-objc-common.cc:330
  2024-05-30  7:50 [Bug c/115290] New: tree check fail in c_tree_printer, at c/c-objc-common.cc:330 dcb314 at hotmail dot com
  2024-05-30 14:50 ` [Bug c/115290] [12/13/14/15 Regression] " pinskia at gcc dot gnu.org
@ 2024-05-31  6:45 ` rguenth at gcc dot gnu.org
  2024-06-17 13:20 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-31  6:45 UTC (permalink / raw)
  To: gcc-bugs

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

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/115290] [12/13/14/15 Regression] tree check fail in c_tree_printer, at c/c-objc-common.cc:330
  2024-05-30  7:50 [Bug c/115290] New: tree check fail in c_tree_printer, at c/c-objc-common.cc:330 dcb314 at hotmail dot com
  2024-05-30 14:50 ` [Bug c/115290] [12/13/14/15 Regression] " pinskia at gcc dot gnu.org
  2024-05-31  6:45 ` rguenth at gcc dot gnu.org
@ 2024-06-17 13:20 ` jakub at gcc dot gnu.org
  2024-06-17 17:24 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-06-17 13:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 58449
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58449&action=edit
gcc15-pr115290.patch

Untested fix.

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

* [Bug c/115290] [12/13/14/15 Regression] tree check fail in c_tree_printer, at c/c-objc-common.cc:330
  2024-05-30  7:50 [Bug c/115290] New: tree check fail in c_tree_printer, at c/c-objc-common.cc:330 dcb314 at hotmail dot com
                   ` (2 preceding siblings ...)
  2024-06-17 13:20 ` jakub at gcc dot gnu.org
@ 2024-06-17 17:24 ` cvs-commit at gcc dot gnu.org
  2024-06-17 17:27 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-17 17:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC 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:b63c7d92012f92e0517190cf263d29bbef8a06bf

commit r15-1381-gb63c7d92012f92e0517190cf263d29bbef8a06bf
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Jun 17 19:24:05 2024 +0200

    c-family: Fix -Warray-compare warning ICE [PR115290]

    The warning code uses %D to print the ARRAY_REF first operands.
    That works in the most common case where those operands are decls, but
    as can be seen on the following testcase, they can be other expressions
    with array type.
    Just changing %D to %E isn't enough, because then the diagnostics can
    suggest something like
    note: use '&(x) != 0 ? (int (*)[32])&a : (int (*)[32])&b[0] == &(y) != 0 ?
(int (*)[32])&a : (int (*)[32])&b[0]' to compare the addresses
    which is a bad suggestion, the %E printing doesn't know that the
    warning code will want to add & before it and [0] after it.
    So, the following patch adds ()s around the operand as well, but does
    that only for non-decls, for decls keeps it as &arr[0] like before.

    2024-06-17  Jakub Jelinek  <jakub@redhat.com>

            PR c/115290
            * c-warn.cc (do_warn_array_compare): Use %E rather than %D for
            printing op0 and op1; if those operands aren't decls, also print
            parens around them.

            * c-c++-common/Warray-compare-3.c: New test.

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

* [Bug c/115290] [12/13/14/15 Regression] tree check fail in c_tree_printer, at c/c-objc-common.cc:330
  2024-05-30  7:50 [Bug c/115290] New: tree check fail in c_tree_printer, at c/c-objc-common.cc:330 dcb314 at hotmail dot com
                   ` (3 preceding siblings ...)
  2024-06-17 17:24 ` cvs-commit at gcc dot gnu.org
@ 2024-06-17 17:27 ` cvs-commit at gcc dot gnu.org
  2024-06-17 17:28 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-17 17:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:922648759b034c356e7d5c1ae530bdb6f3d00c62

commit r14-10322-g922648759b034c356e7d5c1ae530bdb6f3d00c62
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Jun 17 19:24:05 2024 +0200

    c-family: Fix -Warray-compare warning ICE [PR115290]

    The warning code uses %D to print the ARRAY_REF first operands.
    That works in the most common case where those operands are decls, but
    as can be seen on the following testcase, they can be other expressions
    with array type.
    Just changing %D to %E isn't enough, because then the diagnostics can
    suggest something like
    note: use '&(x) != 0 ? (int (*)[32])&a : (int (*)[32])&b[0] == &(y) != 0 ?
(int (*)[32])&a : (int (*)[32])&b[0]' to compare the addresses
    which is a bad suggestion, the %E printing doesn't know that the
    warning code will want to add & before it and [0] after it.
    So, the following patch adds ()s around the operand as well, but does
    that only for non-decls, for decls keeps it as &arr[0] like before.

    2024-06-17  Jakub Jelinek  <jakub@redhat.com>

            PR c/115290
            * c-warn.cc (do_warn_array_compare): Use %E rather than %D for
            printing op0 and op1; if those operands aren't decls, also print
            parens around them.

            * c-c++-common/Warray-compare-3.c: New test.

    (cherry picked from commit b63c7d92012f92e0517190cf263d29bbef8a06bf)

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

* [Bug c/115290] [12/13/14/15 Regression] tree check fail in c_tree_printer, at c/c-objc-common.cc:330
  2024-05-30  7:50 [Bug c/115290] New: tree check fail in c_tree_printer, at c/c-objc-common.cc:330 dcb314 at hotmail dot com
                   ` (4 preceding siblings ...)
  2024-06-17 17:27 ` cvs-commit at gcc dot gnu.org
@ 2024-06-17 17:28 ` cvs-commit at gcc dot gnu.org
  2024-06-17 17:30 ` [Bug c/115290] [12 " jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-17 17:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

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

commit r13-8854-gbe14e6cf7f2dc23012dfced0a4aff0894fd6ff57
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Jun 17 19:24:05 2024 +0200

    c-family: Fix -Warray-compare warning ICE [PR115290]

    The warning code uses %D to print the ARRAY_REF first operands.
    That works in the most common case where those operands are decls, but
    as can be seen on the following testcase, they can be other expressions
    with array type.
    Just changing %D to %E isn't enough, because then the diagnostics can
    suggest something like
    note: use '&(x) != 0 ? (int (*)[32])&a : (int (*)[32])&b[0] == &(y) != 0 ?
(int (*)[32])&a : (int (*)[32])&b[0]' to compare the addresses
    which is a bad suggestion, the %E printing doesn't know that the
    warning code will want to add & before it and [0] after it.
    So, the following patch adds ()s around the operand as well, but does
    that only for non-decls, for decls keeps it as &arr[0] like before.

    2024-06-17  Jakub Jelinek  <jakub@redhat.com>

            PR c/115290
            * c-warn.cc (do_warn_array_compare): Use %E rather than %D for
            printing op0 and op1; if those operands aren't decls, also print
            parens around them.

            * c-c++-common/Warray-compare-3.c: New test.

    (cherry picked from commit b63c7d92012f92e0517190cf263d29bbef8a06bf)

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

* [Bug c/115290] [12 Regression] tree check fail in c_tree_printer, at c/c-objc-common.cc:330
  2024-05-30  7:50 [Bug c/115290] New: tree check fail in c_tree_printer, at c/c-objc-common.cc:330 dcb314 at hotmail dot com
                   ` (5 preceding siblings ...)
  2024-06-17 17:28 ` cvs-commit at gcc dot gnu.org
@ 2024-06-17 17:30 ` jakub at gcc dot gnu.org
  2024-06-20  8:54 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-06-17 17:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[12/13/14/15 Regression]    |[12 Regression] tree check
                   |tree check fail in          |fail in c_tree_printer, at
                   |c_tree_printer, at          |c/c-objc-common.cc:330
                   |c/c-objc-common.cc:330      |

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Should be fixed for 13.4+/14.2+/15.1+ for now, 12 branch is frozen right now,
so it will need to wait for 12.5.

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

* [Bug c/115290] [12 Regression] tree check fail in c_tree_printer, at c/c-objc-common.cc:330
  2024-05-30  7:50 [Bug c/115290] New: tree check fail in c_tree_printer, at c/c-objc-common.cc:330 dcb314 at hotmail dot com
                   ` (6 preceding siblings ...)
  2024-06-17 17:30 ` [Bug c/115290] [12 " jakub at gcc dot gnu.org
@ 2024-06-20  8:54 ` cvs-commit at gcc dot gnu.org
  2024-06-20  9:15 ` rguenth at gcc dot gnu.org
  2024-06-20  9:32 ` jakub at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-20  8:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:8f612e6559b39569747894ec0f8b4694b96492a7

commit r12-10568-g8f612e6559b39569747894ec0f8b4694b96492a7
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Jun 17 19:24:05 2024 +0200

    c-family: Fix -Warray-compare warning ICE [PR115290]

    The warning code uses %D to print the ARRAY_REF first operands.
    That works in the most common case where those operands are decls, but
    as can be seen on the following testcase, they can be other expressions
    with array type.
    Just changing %D to %E isn't enough, because then the diagnostics can
    suggest something like
    note: use '&(x) != 0 ? (int (*)[32])&a : (int (*)[32])&b[0] == &(y) != 0 ?
(int (*)[32])&a : (int (*)[32])&b[0]' to compare the addresses
    which is a bad suggestion, the %E printing doesn't know that the
    warning code will want to add & before it and [0] after it.
    So, the following patch adds ()s around the operand as well, but does
    that only for non-decls, for decls keeps it as &arr[0] like before.

    2024-06-17  Jakub Jelinek  <jakub@redhat.com>

            PR c/115290
            * c-warn.cc (do_warn_array_compare): Use %E rather than %D for
            printing op0 and op1; if those operands aren't decls, also print
            parens around them.

            * c-c++-common/Warray-compare-3.c: New test.

    (cherry picked from commit b63c7d92012f92e0517190cf263d29bbef8a06bf)

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

* [Bug c/115290] [12 Regression] tree check fail in c_tree_printer, at c/c-objc-common.cc:330
  2024-05-30  7:50 [Bug c/115290] New: tree check fail in c_tree_printer, at c/c-objc-common.cc:330 dcb314 at hotmail dot com
                   ` (7 preceding siblings ...)
  2024-06-20  8:54 ` cvs-commit at gcc dot gnu.org
@ 2024-06-20  9:15 ` rguenth at gcc dot gnu.org
  2024-06-20  9:32 ` jakub at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-20  9:15 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|12.4                        |12.5

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 12.4 is being released, retargeting bugs to GCC 12.5.

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

* [Bug c/115290] [12 Regression] tree check fail in c_tree_printer, at c/c-objc-common.cc:330
  2024-05-30  7:50 [Bug c/115290] New: tree check fail in c_tree_printer, at c/c-objc-common.cc:330 dcb314 at hotmail dot com
                   ` (8 preceding siblings ...)
  2024-06-20  9:15 ` rguenth at gcc dot gnu.org
@ 2024-06-20  9:32 ` jakub at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-06-20  9:32 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 12.5 as well.

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

end of thread, other threads:[~2024-06-20  9:32 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-30  7:50 [Bug c/115290] New: tree check fail in c_tree_printer, at c/c-objc-common.cc:330 dcb314 at hotmail dot com
2024-05-30 14:50 ` [Bug c/115290] [12/13/14/15 Regression] " pinskia at gcc dot gnu.org
2024-05-31  6:45 ` rguenth at gcc dot gnu.org
2024-06-17 13:20 ` jakub at gcc dot gnu.org
2024-06-17 17:24 ` cvs-commit at gcc dot gnu.org
2024-06-17 17:27 ` cvs-commit at gcc dot gnu.org
2024-06-17 17:28 ` cvs-commit at gcc dot gnu.org
2024-06-17 17:30 ` [Bug c/115290] [12 " jakub at gcc dot gnu.org
2024-06-20  8:54 ` cvs-commit at gcc dot gnu.org
2024-06-20  9:15 ` rguenth at gcc dot gnu.org
2024-06-20  9:32 ` 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).