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

            Bug ID: 41100
           Summary: "in call to f(x)" note should pretty-print original
                    value of argument 'x', not mutated value
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: arthur.j.odw...@gmail.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
                    neeil...@live.com, richard-l...@metafoo.co.uk

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:

```
// https://godbolt.org/z/PIL0lW
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.
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to