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

Bitwise OR of oroApi elements is not an oroApi element #112

Open
yusuke-tokuyoshi opened this issue Dec 24, 2024 · 0 comments
Open

Bitwise OR of oroApi elements is not an oroApi element #112

yusuke-tokuyoshi opened this issue Dec 24, 2024 · 0 comments

Comments

@yusuke-tokuyoshi
Copy link

Orochi/Orochi/Orochi.h

Lines 1161 to 1170 in e8da229

enum oroApi
{
ORO_API_AUTOMATIC = 1<<0,
ORO_API_HIPDRIVER = 1 << 1,
ORO_API_HIPRTC = 1 << 2,
ORO_API_HIP = ORO_API_HIPDRIVER | ORO_API_HIPRTC,
ORO_API_CUDADRIVER = 1 << 3,
ORO_API_CUDARTC = 1 << 4,
ORO_API_CUDA = ORO_API_CUDADRIVER | ORO_API_CUDARTC,
};

The union (i.e., bitwise OR operation) of oroApi elements is not an element of oroApi. But the current API deign forces us to cast the union to oroApi, such as oroInitialize(static_cast<oroApi>(ORO_API_HIP | ORO_API_CUDA,.
int oroInitialize( oroApi api, oroU32 flags,

For this case, the Clang analyzer can detect the out of range for oroApi and warns. To avoid such out of range, it may be better to change the function parameter type from oroApi to uint32_t.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant