Skip to content

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

Closed
@jackua22

Description

@jackua22

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions