https://bugs.llvm.org/show_bug.cgi?id=39868

            Bug ID: 39868
           Summary: Wrong value for induction variable after a loop (at
                    -O1)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedb...@nondot.org
          Reporter: dav...@freebsd.org
                CC: jdevliegh...@apple.com, keith.wal...@arm.com,
                    llvm-bugs@lists.llvm.org,
                    paul_robin...@playstation.sony.com

$ cat a.c
int a;
int b() {
  int i;
  for (i = 0; i < 2; i++)
    ;
  patatino();
  return a;
}
int main() { b(); }

$ cat b.c
void patatino() {}

Davides-MacBook-Pro:bin dcci$ ./clang a.c b.c -g -O1

Current executable set to './a.out' (x86_64).
(lldb) br set -p patatino
Breakpoint 1: where = a.out`b + 4 at a.c:6:3, address = 0x0000000100000f84
(lldb) r
Process 24530 launched: '/Users/dcci/work/llvm/build-debug/bin/a.out' (x86_64)
a.out was compiled with optimization - stepping may behave oddly; variables may
not be available.
Process 24530 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100000f84 a.out`b at a.c:6:3 [opt]
   3      int i;
   4      for (i = 0; i < 2; i++)
   5        ;
-> 6      patatino();
   7      return a;
   8    }
   9    int main() { b(); }
(lldb) frame var i
(int) i = 0

This should be either “unavailable”, or “i = 2”. i = 0 is a lie.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to