public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/112565] New: Abnormal Jump in Execution using 'stepi' Command in GDB under O2 optimization
@ 2023-11-16 11:51 iamanonymous.cs at gmail dot com
  2023-11-16 11:55 ` [Bug debug/112565] " vries at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: iamanonymous.cs at gmail dot com @ 2023-11-16 11:51 UTC (permalink / raw)
  To: gcc-bugs

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

            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=31070

Tom de Vries suggests that this issue may be attributed to a GCC optimization
bug.


$ cat small.c
int glob_int_arr[100];
int *glob_ptr_int = 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 

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)


=================================================
When using the 'stepi' command in GDB, an abnormal jump in the execution occurs
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 <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

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

end of thread, other threads:[~2023-11-16 14:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-16 11:51 [Bug debug/112565] New: Abnormal Jump in Execution using 'stepi' Command in GDB under O2 optimization iamanonymous.cs at gmail dot com
2023-11-16 11:55 ` [Bug debug/112565] " vries at gcc dot gnu.org
2023-11-16 12:00 ` iamanonymous.cs at gmail dot com
2023-11-16 12:42 ` iamanonymous.cs at gmail dot com
2023-11-16 12:47 ` rguenth at gcc dot gnu.org
2023-11-16 14:26 ` iamanonymous.cs at gmail dot com

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).