Skip to content

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

@yusuke-tokuyoshi

Description

@yusuke-tokuyoshi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions