Enforcing stricter compilation warnings and fixing enum typing #322
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On Linux (gcc, clang) and MacOS (clang), the flags
-Wextraand-Wpedanticcan be used in addition to the not-so-aptly-named-Wallto catch additional mishaps.Clang caught one minor issue with the enums
INVALID_VALUEandSPV_REFLECT_EXECUTION_MODE_SPEC_CONSTANT, which are constants set to0xFFFFFFFF. Stricly speaking, the hexadecimal is anunsigned 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 thanintare a specific extension in C, so this would be the more "correct" solution.GCC 15 caught an issue regarding the cast from
INVALID_VALUEtoSpvStorageClass, writing tostorage_classofSpvReflectTypeDescription.SPIRV-Reflect/spirv_reflect.h
Lines 390 to 406 in 94e1c5e
storage_classis 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 intbeforehand to resolve issues with sign differences (most flags seem to be ofunsigned int).