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

unsuppressable error about invalid bitwise operation between different enumeration types #92340

Open
jackua22 opened this issue May 16, 2024 · 1 comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer

Comments

@jackua22
Copy link

We use Infiniband API installed on hundreds of servers in our farm. It is in /usr/include/infiniband/verbs.h. For R&D, it is third-party software.
This program
#include <infiniband/verbs.h>
Then compilation fails like this

/grid/common/test/llvm-v18.1.1d1rh74_lnx86/bin/clang++ -c -std=c++26 -Wno-error -Wno-enum-conversion -Wno-deprecated-anon-enum-enum-conversion enum.cpp
In file included from enum.cpp:1:
/usr/include/infiniband/verbs.h:550:53: error: invalid bitwise operation between different enumeration types ('(unnamed enum at /usr/include/infiniband/verbs.h:539:1)' and 'ibv_create_cq_wc_flags')
  550 |         IBV_CREATE_CQ_SUP_WC_FLAGS = IBV_WC_STANDARD_FLAGS |
      |                                      ~~~~~~~~~~~~~~~~~~~~~ ^
  551 |                                 IBV_WC_EX_WITH_COMPLETION_TIMESTAMP |
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

With -std=++2b, it does not.
The error is correct. What is incorrect is that the error has no ID and cannot be suppressed in any known way.
According to this page
https://clang.llvm.org/docs/DiagnosticsReference.html#wanon-enum-enum-conversion
I can make the second enum anon, too, by adding -Dibv_create_cq_wc_flags= to the command line. The error changes but stays an error:

/usr/include/infiniband/verbs.h:550:53: error: invalid bitwise operation between different enumeration types ('(unnamed enum at /usr/include/infiniband/verbs.h:539:1)' and
      '(unnamed enum at /usr/include/infiniband/verbs.h:524:1)')

This is a wrong general situation, every message must have an ID and be suppressable.
This is some info about the header:
-rw-r--r-- 1 root root 92862 Mar 22 2021 /usr/include/infiniband/verbs.h
a07809625d1024f1dfdf3db62a66ce88 /usr/include/infiniband/verbs.h
I am unsure if copying a couple of lines from that header to this ticket is a good idea.

@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 May 16, 2024
@shafik
Copy link
Collaborator

shafik commented May 16, 2024

CC @cor3ntin I think this is 1cbd52f

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