[llvm-bugs] [Bug 45923] New: Wrong variable value shown during debugging at Og

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 14 00:36:51 PDT 2020


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

            Bug ID: 45923
           Summary: Wrong variable value shown during debugging at Og
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: massarelli at diag.uniroma1.it
                CC: ditaliano at apple.com, htmldeveloper at gmail.com,
                    llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

At line 13 value 1 should be assigned to variable f while -1 is shown in lldb
and gdb.

$ cat a.c
typedef unsigned uint32_t;
int(a)(b) { return b; }
char c;
uint32_t d;
static int func_5(uint32_t p_6) {
  for (; c; c = 5)
    p_6 || d;
}
int e;
int main() {
  int f;
  e = a(8);
  f = e && 9;
  func_5(f);
}

$ clang -v
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
c25b20c0f6c13d68dbc2e185764082d61ae4a132)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation:
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/11.0.0
Selected GCC installation: /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/11.0.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

$ lldb -v
lldb version 11.0.0
  clang revision c25b20c0f6c13d68dbc2e185764082d61ae4a132
  llvm revision c25b20c0f6c13d68dbc2e185764082d61ae4a132

$ gdb -v
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git

$ clang -O3 -g -o opt a.c

$ lldb opt
(lldb) target create "opt"
Current executable set to 'opt' (x86_64).
(lldb) b main
Breakpoint 1: where = opt`main at a.c:12:5, address = 0x0000000000400490
(lldb) r
Process 117 launched: 'opt' (x86_64)
Process 117 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400490 opt`main at a.c:12:5
   9    int e;
   10   int main() {
   11     int f;
-> 12     e = a(8);
   13     f = e && 9;
   14     func_5(f);
   15   }
(lldb) n
Process 117 stopped
* thread #1, name = 'opt', stop reason = step over
    frame #0: 0x000000000040049a opt`main at a.c:14
   11     int f;
   12     e = a(8);
   13     f = e && 9;
-> 14     func_5(f);
   15   }
(lldb) p f
(int) $0 = -1
(lldb) p e 
(int) $1 = 8
(lldb) expr e && 8
(bool) $2 = true

$ gdb opt
(gdb) b main
Breakpoint 1 at 0x400490: file a.c, line 12.
(gdb) r
Starting program: opt 

Breakpoint 1, main () at a.c:12
12        e = a(8);
(gdb) s
14        func_5(f);
(gdb) p f
$1 = -1
(gdb)

-- 
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/20200514/a7079d16/attachment.html>


More information about the llvm-bugs mailing list