Issue 172279
Summary -Wsign-conversion should consider control-flow sentive range and only warn if problematic numbers are possible
Labels new issue
Assignees
Reporter RedBeard0531
    The following code is perfectly fine, but currently generates a bogus warning:

```cpp
int f(unsigned);
int test(int i) {
    if (i < 0)
        return 0;
    return f(i);
}
```

```
<source>:7:14: warning: implicit conversion changes signedness: 'int' to 'unsigned int' [-Wsign-conversion]
    7 |     return f(i);
      |            ~ ^
```

`i` can never be negative at that point (and I'm pretty sure other warnings know that), so there shouldn't be a warning when it gets converted to unsigned.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to