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

            Bug ID: 89792
           Summary: gcc generates wrong debug information at -O3
           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 affects gcc-8 and gcc-trunk. gcc-7 works fine.

The testcase looks similar to Bug 89463. But they affect different gcc versions
and bisect points to different revisions. It would be helpful to have them
fixed.

For this bug, bisect points to r255569.



$ cat abc.c
volatile int a, b;
static int c;
int main() {
  int i;
  b = 0;
  i = 0;
  for (; i < 3; i++)
    a = c;
  i = 0;
  for (; i < 5; i++)
    ;
  optimize_me_not();
}

$ cat outer.c
void optimize_me_not() {}

$ cat cmds
b 12
r
p i
kill
q



#Correct output#
$ gcc-trunk -g  abc.c outer.c
$ gdb -x cmds -batch a.out
Breakpoint 1 at 0x400496: file abc.c, line 12.

Breakpoint 1, main () at abc.c:12
12        optimize_me_not();
$1 = 5

#Wrong output#
$ gcc-trunk -g -O3 abc.c outer.c
$ gdb -x cmds -batch a.out
Breakpoint 1 at 0x4003ae: file abc.c, line 12.

Breakpoint 1, main () at abc.c:12
12        optimize_me_not();
$1 = 0

Reply via email to