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

            Bug ID: 94018
           Summary: gcc generates wrong debug information at -Og
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: qrzhang at gatech dot edu
  Target Milestone: ---

It appears to be a recent regression. Gcc-9 works fine. It happens at -Og only.

Bisection points to g:ec8ac265ff21fb379ac072848561a91e4990c47f


$ gcc-trunk -v
gcc version 10.0.1 20200303 (experimental) [master revision
3d6fd7ce6dc:a5d64750934:b07e4e7c7520ca3e798f514dec0711eea2c027be] (GCC)


#expected output.

$ gcc-trunk -g abc.c
$ gdb -x cmds -batch a.out
Breakpoint 1 at 0x40048f: file abc.c, line 5.

Breakpoint 1, main () at abc.c:5
5           b = (l = a) || 1; //    optimize_me_not()
$1 = 2
Kill the program being debugged? (y or n) [answered Y; input not from terminal]
[Inferior 1 (process 25509) killed]


#wrong output
$ gcc-trunk -g -Og abc.c
$ gdb -x cmds -batch a.out
Breakpoint 1 at 0x400484: file abc.c, line 5.

Breakpoint 1, main () at abc.c:5
5           b = (l = a) || 1; //    optimize_me_not()
$1 = 0
Kill the program being debugged? (y or n) [answered Y; input not from terminal]
[Inferior 1 (process 20078) killed]



$ cat abc.c
static int a, b, c;
int main() {
  int l = 2;
  for (; c < 2; c++)
    b = (l = a) || 1; //    optimize_me_not()
  a = 0;
}


$ cat cmds
b abc.c:5
r
p l
kill
q

Reply via email to