[lldb-dev] [Bug 45564] New: lldb printing shadowed local variable

via lldb-dev lldb-dev at lists.llvm.org
Wed Apr 15 15:24:03 PDT 2020


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

            Bug ID: 45564
           Summary: lldb printing shadowed local variable
           Product: lldb
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: vsk at apple.com
                CC: jdevlieghere at apple.com, llvm-bugs at lists.llvm.org

When we compile the following program at -O0 and step to the third printf, lldb
prints two values for "l", which is misleading. It should just print the
unshadowed one.

```
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
    frame #0: 0x0000000100000f69 opt`main(argc=1, argv=0x00007ffeefbff8a8) at
opt.c:10:20
   7      {
   8        printf("%d\n", l);
   9        int l = 7;
-> 10       printf("%d\n", l);
   11     }
   12  
   13     return 0;
(lldb) frame variable
(int) argc = 1
(char **) argv = 0x00007ffeefbff8a8
(int) l = 6
(int) l = 7
```

Program:

```
#include <stdio.h>

int main(int argc, char **argv) {
  int l = 6;
  printf("%d\n", l);

  {
    printf("%d\n", l);
    int l = 7;
    printf("%d\n", l);
  }

  return 0;
}

```

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20200415/6d12613d/attachment.html>


More information about the lldb-dev mailing list