From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 83F9E3858C50; Thu, 16 Nov 2023 11:51:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83F9E3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700135474; bh=BEjgxfN6MkMaGZ+sNuEp/i+bhwKGsaQ+o9RMR5uZ6MY=; h=From:To:Subject:Date:From; b=kDDboXeQavKsYQUDmEm2s7p9FNp+UOqQ5QK3d83SMc99oBYBCecKzPtjQjeEXvvQl EEM9LqaHgm8V2Vvx/So/nKBKvY5Huzm8VMVLF2Qc/IBIWi6rz6mAKxd8fpKS+i6OPv hO+m2kTca/LVn6t5ZL2rqVxc+PPY8w+3ouFnZ3bc= From: "iamanonymous.cs at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/112565] New: Abnormal Jump in Execution using 'stepi' Command in GDB under O2 optimization Date: Thu, 16 Nov 2023 11:51:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: iamanonymous.cs at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112565 Bug ID: 112565 Summary: Abnormal Jump in Execution using 'stepi' Command in GDB under O2 optimization Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: iamanonymous.cs at gmail dot com Target Milestone: --- Bug reported initially reported: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31070 Tom de Vries suggests that this issue may be attributed to a GCC optimizati= on bug. $ cat small.c int glob_int_arr[100]; int *glob_ptr_int =3D glob_int_arr; void simple_global () { __builtin_prefetch (glob_int_arr, 0, 0); __builtin_prefetch (glob_ptr_int, 0, 0); } int main() { simple_global (); exit (0); } $ gcc -w -O2 -g small.c; gdb -q a.out Reading symbols from a.out... (gdb) b main Breakpoint 1 at 0x401040: file small.c, line 6. (gdb) r Starting program: /root/devil/a.out=20 Breakpoint 1, main () at small.c:6 6 __builtin_prefetch (glob_int_arr, 0, 0); (gdb) si 0x0000000000401044 in simple_global () at small.c:7 7 __builtin_prefetch (glob_ptr_int, 0, 0); (gdb) si 0x000000000040104b in main () at small.c:13 13 exit (0); (gdb) si 0x000000000040104d in simple_global () at small.c:6 6 __builtin_prefetch (glob_int_arr, 0, 0); (gdb) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D When using the 'stepi' command in GDB, an abnormal jump in the execution oc= curs when reaching line 7 of the code. The execution unexpectedly jumps to line = 13. $ gcc --version gcc (GCC) 14.0.0 20231116 (experimental) Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ gdb --version GNU gdb (GDB) 15.0.50.20231116-git Copyright (C) 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.=