[llvm-bugs] [Bug 39868] New: Wrong value for induction variable after a loop (at -O1)

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Dec 3 07:56:58 PST 2018


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: unassignedbugs at nondot.org
          Reporter: davide at freebsd.org
                CC: jdevlieghere at apple.com, keith.walker at arm.com,
                    llvm-bugs at lists.llvm.org,
                    paul_robinson at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181203/730b0200/attachment.html>


More information about the llvm-bugs mailing list