<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 - "in call to f(x)" note should pretty-print original value of argument 'x', not mutated value"
   href="https://bugs.llvm.org/show_bug.cgi?id=41100">41100</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>"in call to f(x)" note should pretty-print original value of argument 'x', not mutated value
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>arthur.j.odwyer@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When Clang prints diagnostic notes of the form "...in call to f(arg1,
arg2)...", it seems to lose track of the arguments' ORIGINAL values. Clang ends
up pretty-printing the CHANGED values of those arguments. This can be very
confusing, especially when there's recursion involved, because the text of the
diagnostic will appear to be talking about a call that never appears in the
source code (or worse, a call that coincidentally DOES appear in the source
code, but isn't the culprit). Here's a reduced test case:

```
// <a href="https://godbolt.org/z/PIL0lW">https://godbolt.org/z/PIL0lW</a>
constexpr int f(int i) {
    i = -i;
    return 1 << i;
}
static_assert(f(1));
```

The problematic part of the following error message is where it mentions "call
to 'f(-1)'". It should mention "call to 'f(1)'" instead.

```
<source>:7:15: error: static_assert expression is not an integral constant
expression
static_assert(f(1));
              ^~~~
<source>:4:14: note: negative shift count -1
    return 1 << i;
             ^
<source>:7:15: note: in call to 'f(-1)'
static_assert(f(1));
              ^
1 error generated.
```</pre>
        </div>
      </p>


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

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>