| Issue |
64741
|
| Summary |
clang -Wconstant-conversion conditional operator false positive
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
osandov
|
The following C source code:
```c
int x = 0 ? 9223372036854775807L : 2147483648;
```
Produces the following warning when compiled with Clang:
```console
$ clang --version
clang version 16.0.6 (Fedora 16.0.6-2.fc38)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ clang -Wconstant-conversion -fsyntax-only test.c
test.c:1:13: warning: implicit conversion from 'long' to 'int' changes value from 9223372036854775807 to -1 [-Wconstant-conversion]
int x = 0 ? 9223372036854775807L : 2147483647;
~ ^~~~~~~~~~~~~~~~~~~~
1 warning generated.
```
`0 ? 9223372036854775807L : 2147483647` evaluates to `2147483647L`, so this warning is incorrect. GCC's similar `-Woverflow` doesn't trigger for this test case.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs