Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang misses left shift count warning found by gcc #59863

Open
jstengleingithub opened this issue Jan 6, 2023 · 2 comments
Open

Clang misses left shift count warning found by gcc #59863

jstengleingithub opened this issue Jan 6, 2023 · 2 comments
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer

Comments

@jstengleingithub
Copy link
Contributor

jstengleingithub commented Jan 6, 2023

Clang misses a shift count warning found by GCC.

cat shift.c
#include <stdio.h>
typedef enum shiftof {
    OFA_FM_POL_ERROR = (1<<32)
} shiftof_t;

int main()
{
    printf ("%u %lu %lu\n", OFA_FM_POL_ERROR, sizeof(OFA_FM_POL_ERROR), sizeof(shiftof_t));
}
$ ./bin/clang -Wall shift.c
(no warning)
$ gcc -Wall shift.c
shift.c:3:26: warning: left shift count >= width of type [-Wshift-count-overflow]
     OFA_FM_POL_ERROR = (1<<32)
                          ^~
$ gcc --version
gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-10)
$ ./bin/clang --version
clang version 16.0.0 (https://github.com/llvm/llvm-project 6daa983c9dde7608bcaa20b11e4a7d28fab4e003)
@EugeneZelenko EugeneZelenko added clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer and removed new issue labels Jan 6, 2023
@chestnykh
Copy link

Proposed fix: https://reviews.llvm.org/D141192

@chestnykh
Copy link

Need review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Projects
None yet
Development

No branches or pull requests

3 participants