public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105972] New: [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312
@ 2022-06-14 10:27 gscfq@t-online.de
  2022-06-15  9:06 ` [Bug c/105972] " rguenth at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: gscfq@t-online.de @ 2022-06-14 10:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105972
           Summary: [12/13 Regression] ICE in lower_stmt, at
                    gimple-low.cc:312
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Started between 20211017 and 20211024 :
(gcc configured with --enable-checking=yes)


$ cat z1.c
__attribute__((optimize(0)))
int f ()
{
  int g ()
}


$ gcc-13-20220612 -c z1.c -g -O2
z1.c: In function 'g':
z1.c:5:1: error: expected declaration specifiers before '}' token
    5 | }
      | ^
z1.c:6: error: expected '{' at end of input
z1.c: In function 'f':
z1.c:5:1: error: expected declaration or statement at end of input
    5 | }
      | ^
during GIMPLE pass: lower
z1.c:2:5: internal compiler error: in lower_stmt, at gimple-low.cc:312
    2 | int f ()
      |     ^
0x1c2901d lower_stmt
        ../../gcc/gimple-low.cc:312
0x1c2901d lower_sequence
        ../../gcc/gimple-low.cc:217
0x1c27d79 lower_gimple_bind
        ../../gcc/gimple-low.cc:475
0x1c291a8 lower_function_body
        ../../gcc/gimple-low.cc:110
0x1c291a8 execute
        ../../gcc/gimple-low.cc:195

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

* [Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312
  2022-06-14 10:27 [Bug c/105972] New: [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 gscfq@t-online.de
@ 2022-06-15  9:06 ` rguenth at gcc dot gnu.org
  2022-06-16 13:54 ` [Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4 marxin at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-06-15  9:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-06-15
             Status|UNCONFIRMED                 |NEW
   Target Milestone|---                         |12.2
           Keywords|                            |error-recovery,
                   |                            |ice-checking,
                   |                            |needs-bisection

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  Somehow we get in .original

;; Function f (null)
;; enabled by -tree-original


{
  static int g ();

  # DEBUG BEGIN STMT;
    static int g ();
}

with the error but correctly

;; Function f (null)
;; enabled by -tree-original


{
  extern int g ();


}

with the error fixed.

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

* [Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4
  2022-06-14 10:27 [Bug c/105972] New: [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 gscfq@t-online.de
  2022-06-15  9:06 ` [Bug c/105972] " rguenth at gcc dot gnu.org
@ 2022-06-16 13:54 ` marxin at gcc dot gnu.org
  2022-07-25 16:01 ` 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-06-16 13:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org
           Keywords|needs-bisection             |
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |marxin at gcc dot gnu.org
            Summary|[12/13 Regression] ICE in   |[12/13 Regression] ICE in
                   |lower_stmt, at              |lower_stmt, at
                   |gimple-low.cc:312           |gimple-low.cc:312 since
                   |                            |r12-4608-gb4702276615ff8d4

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with my revision r12-4608-gb4702276615ff8d4, I'll take a look.

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

* [Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4
  2022-06-14 10:27 [Bug c/105972] New: [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 gscfq@t-online.de
  2022-06-15  9:06 ` [Bug c/105972] " rguenth at gcc dot gnu.org
  2022-06-16 13:54 ` [Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4 marxin at gcc dot gnu.org
@ 2022-07-25 16:01 ` rguenth at gcc dot gnu.org
  2022-07-25 16:01 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-07-25 16:01 UTC (permalink / raw)
  To: gcc-bugs

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

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/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4
  2022-06-14 10:27 [Bug c/105972] New: [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2022-07-25 16:01 ` rguenth at gcc dot gnu.org
@ 2022-07-25 16:01 ` rguenth at gcc dot gnu.org
  2023-01-11 12:05 ` marxin at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-07-25 16:01 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P4

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

* [Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4
  2022-06-14 10:27 [Bug c/105972] New: [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2022-07-25 16:01 ` rguenth at gcc dot gnu.org
@ 2023-01-11 12:05 ` marxin at gcc dot gnu.org
  2023-01-11 14:24 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-01-11 12:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> Confirmed.  Somehow we get in .original
> 
> ;; Function f (null)
> ;; enabled by -tree-original
> 
> 
> {
>   static int g ();
> 
>   # DEBUG BEGIN STMT;
>     static int g ();
> }

Hm, here we end up with a nested function whose parsing is probably skipped and
we end up with the wrong options.
Dunno why.

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

* [Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4
  2022-06-14 10:27 [Bug c/105972] New: [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2023-01-11 12:05 ` marxin at gcc dot gnu.org
@ 2023-01-11 14:24 ` jakub at gcc dot gnu.org
  2023-01-11 14:25 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-11 14:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This ICEs also on the valid
__attribute__((optimize(0))) int
foo ()
{
  int
  bar (x)
    int x;
  {
    return x;
  }
  return bar (0);
}
with -O2 -g.
If I comment out the optimize attribute, then with -O2 -g
-fdump-tree-gimple-lineno
one can see:
  [pr105972-2.c:5:3] # DEBUG BEGIN_STMT
  [pr105972-2.c:7:5] # DEBUG BEGIN_STMT
  [pr105972-2.c:11:3] # DEBUG BEGIN_STMT
statements in foo and
  [pr105972-2.c:9:5] # DEBUG BEGIN_STMT
in bar.  The line 7 statement is just incorrect, IMHO shouldn't be added at
all, when parsing the K&R parameter declarations, there is no reasonable code
point to emit those.
For normal K&R functions, they aren't just emitted because

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

* [Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4
  2022-06-14 10:27 [Bug c/105972] New: [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2023-01-11 14:24 ` jakub at gcc dot gnu.org
@ 2023-01-11 14:25 ` jakub at gcc dot gnu.org
  2023-01-11 21:20 ` 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 @ 2023-01-11 14:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 54246
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54246&action=edit
gcc13-pr105972.patch

Untested fix.

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

* [Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4
  2022-06-14 10:27 [Bug c/105972] New: [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2023-01-11 14:25 ` jakub at gcc dot gnu.org
@ 2023-01-11 21:20 ` cvs-commit at gcc dot gnu.org
  2023-02-10 17:45 ` [Bug c/105972] [12 " cvs-commit at gcc dot gnu.org
  2023-02-10 17:55 ` jakub at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-11 21:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:23b4ce18379cd336d99d7c71701be28118905b57

commit r13-5112-g23b4ce18379cd336d99d7c71701be28118905b57
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jan 11 22:18:42 2023 +0100

    c: Don't emit DEBUG_BEGIN_STMTs for K&R function argument declarations
[PR105972]

    K&R function parameter declarations are handled by calling
    recursively c_parser_declaration_or_fndef in a loop, where each such
    call will add_debug_begin_stmt at the start.
    Now, if the K&R function definition is not a nested function,
    building_stmt_list_p () is false and so we don't emit the DEBUG_BEGIN_STMTs
    anywhere, but if it is a nested function, we emit it in the containing
    function at the point of the nested function definition.
    As the following testcase shows, it can cause ICEs if the containing
    function has var-tracking disabled but nested function has them enabled,
    as the DEBUG_BEGIN_STMTs are added to the containing function which
    shouldn't have them but MAY_HAVE_DEBUG_MARKER_STMTS is checked already
    for the nested function, or just wrong experience in the debugger.

    The following patch ensures we don't emit any such DEBUG_BEGIN_STMTs for
the
    K&R function parameter declarations even in nested functions.

    2023-01-11  Jakub Jelinek  <jakub@redhat.com>

            PR c/105972
            * c-parser.cc (c_parser_declaration_or_fndef): Disable debug
non-bind
            markers for K&R function parameter declarations of nested
functions.

            * gcc.dg/pr105972.c: New test.

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

* [Bug c/105972] [12 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4
  2022-06-14 10:27 [Bug c/105972] New: [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 gscfq@t-online.de
                   ` (7 preceding siblings ...)
  2023-01-11 21:20 ` cvs-commit at gcc dot gnu.org
@ 2023-02-10 17:45 ` cvs-commit at gcc dot gnu.org
  2023-02-10 17:55 ` jakub at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-10 17:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS 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:c2b33b330c16a97627e987c60a6ca35ed0fdea56

commit r12-9140-gc2b33b330c16a97627e987c60a6ca35ed0fdea56
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jan 11 22:18:42 2023 +0100

    c: Don't emit DEBUG_BEGIN_STMTs for K&R function argument declarations
[PR105972]

    K&R function parameter declarations are handled by calling
    recursively c_parser_declaration_or_fndef in a loop, where each such
    call will add_debug_begin_stmt at the start.
    Now, if the K&R function definition is not a nested function,
    building_stmt_list_p () is false and so we don't emit the DEBUG_BEGIN_STMTs
    anywhere, but if it is a nested function, we emit it in the containing
    function at the point of the nested function definition.
    As the following testcase shows, it can cause ICEs if the containing
    function has var-tracking disabled but nested function has them enabled,
    as the DEBUG_BEGIN_STMTs are added to the containing function which
    shouldn't have them but MAY_HAVE_DEBUG_MARKER_STMTS is checked already
    for the nested function, or just wrong experience in the debugger.

    The following patch ensures we don't emit any such DEBUG_BEGIN_STMTs for
the
    K&R function parameter declarations even in nested functions.

    2023-01-11  Jakub Jelinek  <jakub@redhat.com>

            PR c/105972
            * c-parser.cc (c_parser_declaration_or_fndef): Disable debug
non-bind
            markers for K&R function parameter declarations of nested
functions.

            * gcc.dg/pr105972.c: New test.

    (cherry picked from commit 23b4ce18379cd336d99d7c71701be28118905b57)

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

* [Bug c/105972] [12 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4
  2022-06-14 10:27 [Bug c/105972] New: [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 gscfq@t-online.de
                   ` (8 preceding siblings ...)
  2023-02-10 17:45 ` [Bug c/105972] [12 " cvs-commit at gcc dot gnu.org
@ 2023-02-10 17:55 ` jakub at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-10 17:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for gcc 12.3 too.

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

end of thread, other threads:[~2023-02-10 17:55 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-14 10:27 [Bug c/105972] New: [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 gscfq@t-online.de
2022-06-15  9:06 ` [Bug c/105972] " rguenth at gcc dot gnu.org
2022-06-16 13:54 ` [Bug c/105972] [12/13 Regression] ICE in lower_stmt, at gimple-low.cc:312 since r12-4608-gb4702276615ff8d4 marxin at gcc dot gnu.org
2022-07-25 16:01 ` rguenth at gcc dot gnu.org
2022-07-25 16:01 ` rguenth at gcc dot gnu.org
2023-01-11 12:05 ` marxin at gcc dot gnu.org
2023-01-11 14:24 ` jakub at gcc dot gnu.org
2023-01-11 14:25 ` jakub at gcc dot gnu.org
2023-01-11 21:20 ` cvs-commit at gcc dot gnu.org
2023-02-10 17:45 ` [Bug c/105972] [12 " cvs-commit at gcc dot gnu.org
2023-02-10 17:55 ` 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).