Skip to content

Conversation

@M2-TE
Copy link

@M2-TE M2-TE commented Sep 11, 2025

On Linux (gcc, clang) and MacOS (clang), the flags -Wextra and -Wpedantic can be used in addition to the not-so-aptly-named -Wall to catch additional mishaps.

Clang caught one minor issue with the enums INVALID_VALUE and SPV_REFLECT_EXECUTION_MODE_SPEC_CONSTANT, which are constants set to 0xFFFFFFFF. Stricly speaking, the hexadecimal is an unsigned int, representing a value that the enum (int) cannot represent. To solve this, I simply cast the hexadecimal to an int, which creates an int with all bits set. Enums with an underlying type other than int are a specific extension in C, so this would be the more "correct" solution.

GCC 15 caught an issue regarding the cast from INVALID_VALUE to SpvStorageClass, writing to storage_class of SpvReflectTypeDescription.

typedef struct SpvReflectTypeDescription {
uint32_t id;
SpvOp op;
const char* type_name;
// Non-NULL if type is member of a struct
const char* struct_member_name;
// The storage class (SpvStorageClass) if the type, and -1 if it does not have a storage class.
int storage_class;
SpvReflectTypeFlags type_flags;
SpvReflectDecorationFlags decoration_flags;
struct Traits {
SpvReflectNumericTraits numeric;
SpvReflectImageTraits image;
SpvReflectArrayTraits array;
} traits;

storage_class is already an int, so the cast is both unnecessary and strictly speaking an overflow.

Some comparisons with the enums have them simply cast to unsigned int beforehand to resolve issues with sign differences (most flags seem to be of unsigned int).

@CLAassistant
Copy link

CLAassistant commented Sep 11, 2025

CLA assistant check
All committers have signed the CLA.

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

Successfully merging this pull request may close these issues.

2 participants