Issue 235460
Summary [clang-tidy][false-positive] `misc-const-correctness` warns for _expression_ dependent on pack expansion
Labels clang-tidy, false-positive
Assignees
Reporter tearfur
    https://godbolt.org/z/WWaYT4KPM

Given a function template that has pack expansion and a variable in the function body may or may not be modified depending on the pack expansion. If the not-modified version is instantiated first and the modified version is instantiated later, `misc-const-correctness` falsely warns that the variable should be `const`, even if a the modified version was instantiated.

```
<source>:4:5: warning: variable 'n' of type '__size_t' (aka 'unsigned long') can be declared 'const' [misc-const-correctness]
    4 |     auto n = sizeof(x);
      |     ^
      |          const 
1 warning generated.
```

Current trunk: 54a695fad68b8ca95f69395db1048a99042c9cd1
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to