Fix C++20 -Wdeprecated-enum-enum-conversion warning by using integer types for matrix::num_rows and num_cols#415
Open
NBickford-NV wants to merge 2 commits intoBinomialLLC:masterfrom
Conversation
This fixes a -Wdeprecated-enum-enum-conversion warning on
GCC and Clang when compiling with C++20.
Previously, num_rows and num_cols were members of an
anonymous union within each templated matrix type.
This meant that arithmetic operations between num_rows and
num_cols of different matrices were technically implicitly
converting between different types, resulting in this error:
n file included from basis_universal/encoder/basisu_enc.h:4310,
from basis_universal/encoder/basisu_astc_hdr_6x6_enc.h:3,
from basis_universal/encoder/basisu_astc_hdr_6x6_enc.cpp:2:
basis_universal/encoder/basisu_math.h: In instantiation of ‘bu_math::matrix<(X::num_rows * Y::num_rows), (X::num_cols * Y::num_cols), typename X::scalar_type> bu_math::matrix_kronecker_product(const X&, const Y&) [with X = matrix<2, 2, float>; Y = matrix<1, 2, float>; typename X::scalar_type = float]’:
basis_universal/encoder/basisu_math.h:2411:57: required from here
basis_universal/encoder/basisu_math.h:2362:60: warning: arithmetic between different enumeration types ‘bu_math::matrix<2, 2, float>::<unnamed enum>’ and ‘bu_math::matrix<1, 2, float>::<unnamed enum>’ is deprecated [-Wdeprecated-enum-enum-conversion]
2362 | template<typename X, typename Y> matrix<X::num_rows* Y::num_rows, X::num_cols* Y::num_cols, typename X::scalar_type> matrix_kronecker_product(const X& a, const Y& b)
| ~~~~~~~~^~~~~~~~~~~~~
Changing the types of num_rows and num_cols to uint32_t fixes this.
Co-Authored-By: Mathias Heyer <mheyer@nvidia.com>
Signed-off-by: Nia Bickford <nbickford@nvidia.com>
Signed-off-by: Nia Bickford <nbickford@nvidia.com>
Contributor
|
Thank you! Will merge. |
Contributor
|
This has been merged into basisu v2.0 coming in Jan. 2026. |
Author
|
Thank you Rich! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hi! This fixes a
-Wdeprecated-enum-enum-conversionwarning on GCC and Clang we ran into when compiling basisu's files inside a C++20 project. Basisu's CMakeLists.txt specifies C++17, but this can be reproduced without a custom CMake script by runningThis produces the following warning:
Previously,
num_rowsandnum_colswere members of an anonymous union within each templated matrix type:This meant that arithmetic operations between
num_rowsandnum_colsof different matrix types were technically implicitly converting between different types, resulting in the warning above. Changing the types ofnum_rowsandnum_colstostatic const uint32_tfixes this.Thank you!