public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111921] New: GCC: 14: internal compiler error: Segmentation fault
@ 2023-10-22 10:37 141242068 at smail dot nju.edu.cn
  2023-10-22 16:17 ` [Bug middle-end/111921] [11/12/13/14 Regression] ICE with nested function after an error pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: 141242068 at smail dot nju.edu.cn @ 2023-10-22 10:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111921
           Summary: GCC: 14: internal compiler error: Segmentation fault
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

When compile this program with GCC, gcc segfaults:
```
_Atomic(int) a;
const double b;
int main(void) {
  void f(void *arg) { return ; }
  return a |= b;
}
```

The function definition `f` inside main is essential to trigger this segfault,
without this func, GCC simply reports an error.

Compiler Explorer: https://gcc.godbolt.org/z/P58W6ssaG

The stack dump:
```
<source>: In function 'main':
<source>:5:12: error: invalid operands to binary | (have 'int' and 'double')
    5 |   return a |= b;
      |   ~~~~~~   ^~
      |   |
      |   int
<source>:3:5: internal compiler error: Segmentation fault
    3 | int main(void) {
      |     ^~~~
0x231f49e internal_error(char const*, ...)
        ???:0
0x1462bbc walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ???:0
0xda9275 walk_gimple_op(gimple*, tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
        ???:0
0xda96e9 walk_gimple_stmt(gimple_stmt_iterator*, tree_node*
(*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**,
int*, void*), walk_stmt_info*)
        ???:0
0xda9888 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*,
bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
        ???:0
0xda9761 walk_gimple_stmt(gimple_stmt_iterator*, tree_node*
(*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**,
int*, void*), walk_stmt_info*)
        ???:0
0xda9888 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*,
bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
        ???:0
0xda9761 walk_gimple_stmt(gimple_stmt_iterator*, tree_node*
(*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**,
int*, void*), walk_stmt_info*)
        ???:0
0xda9888 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*,
bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
        ???:0
0x11cef6b lower_nested_functions(tree_node*)
        ???:0
0xbea49e cgraph_node::analyze()
        ???:0
0xbee231 symbol_table::finalize_compilation_unit()
        ???:0
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] 8+ messages in thread

* [Bug middle-end/111921] [11/12/13/14 Regression] ICE with nested function after an error
  2023-10-22 10:37 [Bug c/111921] New: GCC: 14: internal compiler error: Segmentation fault 141242068 at smail dot nju.edu.cn
@ 2023-10-22 16:17 ` pinskia at gcc dot gnu.org
  2023-10-22 16:44 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-22 16:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |error-recovery,
                   |                            |ice-checking,
                   |                            |ice-on-invalid-code,
                   |                            |needs-bisection
            Summary|GCC: 14: internal compiler  |[11/12/13/14 Regression]
                   |error: Segmentation fault   |ICE with nested function
                   |                            |after an error
      Known to work|                            |5.1.0, 5.5.0
          Component|c                           |middle-end
   Target Milestone|---                         |11.5
      Known to fail|                            |6.1.0, 7.1.0, 8.1.0

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

* [Bug middle-end/111921] [11/12/13/14 Regression] ICE with nested function after an error
  2023-10-22 10:37 [Bug c/111921] New: GCC: 14: internal compiler error: Segmentation fault 141242068 at smail dot nju.edu.cn
  2023-10-22 16:17 ` [Bug middle-end/111921] [11/12/13/14 Regression] ICE with nested function after an error pinskia at gcc dot gnu.org
@ 2023-10-22 16:44 ` pinskia at gcc dot gnu.org
  2023-10-31 21:15 ` tkoenig at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-22 16:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-10-22

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

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

* [Bug middle-end/111921] [11/12/13/14 Regression] ICE with nested function after an error
  2023-10-22 10:37 [Bug c/111921] New: GCC: 14: internal compiler error: Segmentation fault 141242068 at smail dot nju.edu.cn
  2023-10-22 16:17 ` [Bug middle-end/111921] [11/12/13/14 Regression] ICE with nested function after an error pinskia at gcc dot gnu.org
  2023-10-22 16:44 ` pinskia at gcc dot gnu.org
@ 2023-10-31 21:15 ` tkoenig at gcc dot gnu.org
  2023-10-31 21:59 ` schwab@linux-m68k.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2023-10-31 21:15 UTC (permalink / raw)
  To: gcc-bugs

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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

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

--- Comment #2 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
gcc 6 to 13 have "confused by earlier errors, bailing out".

The segfault starts occuring in gcc-14.

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

* [Bug middle-end/111921] [11/12/13/14 Regression] ICE with nested function after an error
  2023-10-22 10:37 [Bug c/111921] New: GCC: 14: internal compiler error: Segmentation fault 141242068 at smail dot nju.edu.cn
                   ` (2 preceding siblings ...)
  2023-10-31 21:15 ` tkoenig at gcc dot gnu.org
@ 2023-10-31 21:59 ` schwab@linux-m68k.org
  2023-11-01 17:02 ` [Bug middle-end/111921] [11/12/13/14 Regression] ICE with nested function after an error since r6-205-g5c4abbb8e80153 tkoenig at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: schwab@linux-m68k.org @ 2023-10-31 21:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andreas Schwab <schwab@linux-m68k.org> ---
This is the effect of --enable-checking=release.

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

* [Bug middle-end/111921] [11/12/13/14 Regression] ICE with nested function after an error since r6-205-g5c4abbb8e80153
  2023-10-22 10:37 [Bug c/111921] New: GCC: 14: internal compiler error: Segmentation fault 141242068 at smail dot nju.edu.cn
                   ` (3 preceding siblings ...)
  2023-10-31 21:59 ` schwab@linux-m68k.org
@ 2023-11-01 17:02 ` tkoenig at gcc dot gnu.org
  2024-03-07 21:03 ` law at gcc dot gnu.org
  2024-03-12 13:23 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2023-11-01 17:02 UTC (permalink / raw)
  To: gcc-bugs

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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11/12/13/14 Regression]    |[11/12/13/14 Regression]
                   |ICE with nested function    |ICE with nested function
                   |after an error              |after an error since
                   |                            |r6-205-g5c4abbb8e80153
           Keywords|needs-bisection             |
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #4 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Bisection finally found the relevant patch: r6-205-g5c4abbb8e80153

5c4abbb8e80153999b0298e4b2fe81d512f133c8 is the first bad commit
commit 5c4abbb8e80153999b0298e4b2fe81d512f133c8
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Apr 23 14:35:12 2015 +0000

    re PR c/65345 (ICE with _Generic selection on _Atomic int)

        PR c/65345
        * c-decl.c (set_labels_context_r): New function.
        (store_parm_decls): Call it via walk_tree_without_duplicates.
        * c-typeck.c (convert_lvalue_to_rvalue): Use create_tmp_var_raw
        instead of create_tmp_var.  Build TARGET_EXPR instead of
        COMPOUND_EXPR.
        (build_atomic_assign): Use create_tmp_var_raw instead of
        create_tmp_var.  Build TARGET_EXPRs instead of MODIFY_EXPR.

        * gcc.dg/pr65345-1.c: New test.
        * gcc.dg/pr65345-2.c: New test.

    From-SVN: r222370

Bisection actually needed a patch for bootstrap to succeed:

diff --git a/gcc/cp/cfns.gperf b/gcc/cp/cfns.gperf
index 68acd3d..5ecf86a 100644
--- a/gcc/cp/cfns.gperf
+++ b/gcc/cp/cfns.gperf
@@ -23,7 +23,7 @@ static unsigned int hash (const char *, unsigned int);
 #ifdef __GNUC__
 __inline
 #endif
-const char * libc_name_p (const char *, unsigned int);
+# const char * libc_name_p (const char *, unsigned int);
 %}
 %%
 # The standard C library functions, for feeding to gperf; the result is used
diff --git a/gcc/cp/cfns.h b/gcc/cp/cfns.h
index 1c6665d..ee38f6a 100644
--- a/gcc/cp/cfns.h
+++ b/gcc/cp/cfns.h
@@ -51,9 +51,6 @@ along with GCC; see the file COPYING3.  If not see
 __inline
 #endif
 static unsigned int hash (const char *, unsigned int);
-#ifdef __GNUC__
-__inline
-#endif
 const char * libc_name_p (const char *, unsigned int);
 /* maximum key range = 391, duplicates = 0 */

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

* [Bug middle-end/111921] [11/12/13/14 Regression] ICE with nested function after an error since r6-205-g5c4abbb8e80153
  2023-10-22 10:37 [Bug c/111921] New: GCC: 14: internal compiler error: Segmentation fault 141242068 at smail dot nju.edu.cn
                   ` (4 preceding siblings ...)
  2023-11-01 17:02 ` [Bug middle-end/111921] [11/12/13/14 Regression] ICE with nested function after an error since r6-205-g5c4abbb8e80153 tkoenig at gcc dot gnu.org
@ 2024-03-07 21:03 ` law at gcc dot gnu.org
  2024-03-12 13:23 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-07 21:03 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at gcc dot gnu.org
           Priority|P3                          |P1

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

* [Bug middle-end/111921] [11/12/13/14 Regression] ICE with nested function after an error since r6-205-g5c4abbb8e80153
  2023-10-22 10:37 [Bug c/111921] New: GCC: 14: internal compiler error: Segmentation fault 141242068 at smail dot nju.edu.cn
                   ` (5 preceding siblings ...)
  2024-03-07 21:03 ` law at gcc dot gnu.org
@ 2024-03-12 13:23 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-03-12 13:23 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 6-13 has been released with this bug, so P2.

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

end of thread, other threads:[~2024-03-12 13:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-22 10:37 [Bug c/111921] New: GCC: 14: internal compiler error: Segmentation fault 141242068 at smail dot nju.edu.cn
2023-10-22 16:17 ` [Bug middle-end/111921] [11/12/13/14 Regression] ICE with nested function after an error pinskia at gcc dot gnu.org
2023-10-22 16:44 ` pinskia at gcc dot gnu.org
2023-10-31 21:15 ` tkoenig at gcc dot gnu.org
2023-10-31 21:59 ` schwab@linux-m68k.org
2023-11-01 17:02 ` [Bug middle-end/111921] [11/12/13/14 Regression] ICE with nested function after an error since r6-205-g5c4abbb8e80153 tkoenig at gcc dot gnu.org
2024-03-07 21:03 ` law at gcc dot gnu.org
2024-03-12 13:23 ` 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).