Issue |
135558
|
Summary |
misleading fix-it with `bugprone-unintended-char-ostream-output` in templated code
|
Labels |
clang-tidy
|
Assignees |
|
Reporter |
firewave
|
The fix-it is problematic if it is a templated type and should probably be omitted in that case:
```cpp
#include <cstdint>
#include <sstream>
template<typename T>
void func(const T& data)
{
std::ostringstream ostr;
ostr << data;
}
void f()
{
func((char)0);
func((int8_t)0);
func("");
}
```
```
<source>:8:10: warning: 'signed char' passed to 'operator<<' outputs as character instead of integer. cast to 'unsigned int' to print numeric value or cast to 'char' to print as character [bugprone-unintended-char-ostream-output]
8 | ostr << data;
| ^ ~~~~
| static_cast<int>(data)
```
https://godbolt.org/z/93axK1E4M
_Originally posted by @firewave in https://github.com/llvm/llvm-project/issues/127720#issuecomment-2729734197_
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs