<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - incorrect results of expression evaluation"
   href="https://bugs.llvm.org/show_bug.cgi?id=37840">37840</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>incorrect results of expression evaluation
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lldb
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>lldb-dev@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tianxiao.gu@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=20442" name="attach_20442" title="scripts to reproduce the issue.">attachment 20442</a> <a href="attachment.cgi?id=20442&action=edit" title="scripts to reproduce the issue.">[details]</a></span>
scripts to reproduce the issue.

## Overview

lldb command print/expression produces incorrect values.
This issue can be reproduced with lldb 7.0.

~~~
$ lldb -version
lldb version 7.0.0 (<a href="http://llvm.org/svn/llvm-project/lldb/trunk">http://llvm.org/svn/llvm-project/lldb/trunk</a> revision
334970)
  clang revision 334970
  llvm revision 334970
~~~

## Input Program

~~~~
#include <stdio.h>
#include <stdlib.h>
int main() {
  int32_t g_1974 = 1482617779;
  int16_t g_159  = -7666;
  printf("%d\n", g_1974 & g_159); // break here and see the result of (g_1974 &
g_159)
  return 0;
}
~~~


## Reproduce Steps

The attached zip file contains files that can reproduce the issue.

1. See results of lldb by running `run-lldb.sh`.

(lldb) target create "a.out"
Current executable set to 'a.out' (x86_64).
(lldb) command source -s 0 'lldb-cmds.txt'
Executing commands in '/home/t/<a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Need to add product version numbers"
   href="show_bug.cgi?id=1">bug1</a>/lldb-cmds.txt'.
(lldb) breakpoint set -file test.c -line 7
Breakpoint 1: where = a.out`main + 45 at test.c:7, address = 0x0000000000400553
(lldb) process launch
1482613250
Process 20892 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400553 a.out`main at test.c:7
   4      int32_t g_1974 = 1482617779;
   5      int16_t g_159  = -7666;
   6      printf("%d\n", g_1974 & g_159);
-> 7      return 0;
   8    }

Process 20892 launched: '/home/t/<a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Need to add product version numbers"
   href="show_bug.cgi?id=1">bug1</a>/a.out' (x86_64)
(lldb) print g_1974
(int32_t) $0 = 1482617779
(lldb) print g_159
(int16_t) $1 = -7666
(lldb) print (g_1974 & g_159)
(int) $2 = 57858 <--- HERE SHOULD BE 1482613250

2. Run `run-gdb.sh` for gdb.

Breakpoint 1 at 0x400553: file test.c, line 7.
1482613250

Breakpoint 1, main () at test.c:7
7         return 0;
$1 = 1482617779
$2 = -7666
$3 = 1482613250</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>