Issue 129851
Summary Why Isn't `-Wsign-conversion` Included in `-Wall` and `-Wextra`?
Labels new issue
Assignees
Reporter PikachuHyA
    I find it puzzling that the `-Wsign-conversion` flag is not included in `-Wall -Wextra`. Is there a specific reason for this?

Here's a simple example:

```c
// demo.c
#include <stdio.h>

int main() {
    unsigned long a = 1;
    signed long b = 2;
 printf("%llu\n", (long long unsigned int)(a + b));
    return 0;
}
```

Testing it with the latest Clang compiler:

```
$ ./bin/clang demo.c -Wall -Wextra 

$ ./bin/clang demo.c -Wsign-conversion
demo.c:6:49: warning: implicit conversion changes signedness: 'long' to 'unsigned long' [-Wsign-conversion]
    6 | printf("%llu\n", (long long unsigned int)(a + b));
      | ~ ^
1 warning generated.

$ ./bin/clang demo.c -Werror -Wsign-conversion
demo.c:6:49: error: implicit conversion changes signedness: 'long' to 'unsigned long' [-Werror,-Wsign-conversion]
 6 |   printf("%llu\n", (long long unsigned int)(a + b));
      | ~ ^
1 error generated.
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to