Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

Cannot use |= to paddle_error #56

@Xreki

Description

@Xreki

We use |= to paddle_error in our benchmark.

inline paddle_error& operator |=(paddle_error& a, paddle_error b) {
return a =
static_cast<paddle_error>(static_cast<int>(a) | static_cast<int>(b));
}

However, the definition of paddle_error is:
https://github.com/PaddlePaddle/Paddle/blob/c8d4efb20eecab5a2edd55ccf923dac78afc6d78/paddle/capi/error.h#L23-L30

typedef enum {
  kPD_NO_ERROR = 0,
  kPD_NULLPTR = 1,
  kPD_OUT_OF_RANGE = 2,
  kPD_PROTOBUF_ERROR = 3,
  kPD_NOT_SUPPORTED = 4,
  kPD_UNDEFINED_ERROR = -1,
} paddle_error;

The different bit of different error may be the same. If we use |= to two variables of paddle_error, we may lose the error information.

Also, we need to print the error information, or it will be difficult for users to debug, like in #48 .

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