Skip to content

Conversation

@NBickford-NV
Copy link

Hi! This fixes a -Wdeprecated-enum-enum-conversion warning 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 running

g++ -O3 -DNDEBUG -std=c++20 -o temp.o -c basis_universal/encoder/basisu_astc_hdr_6x6_enc.cpp

This produces the following warning:

in 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)
      |                                                    ~~~~~~~~^~~~~~~~~~~~~

Previously, num_rows and num_cols were members of an anonymous union within each templated matrix type:

	template <uint32_t R, uint32_t C, typename T>
	class matrix
	{
	public:
		typedef T scalar_type;
		enum
		{
			num_rows = R,
			num_cols = C
		};
                ...

This meant that arithmetic operations between num_rows and num_cols of different matrix types were technically implicitly converting between different types, resulting in the warning above. Changing the types of num_rows and num_cols to static const uint32_t fixes this.

Thank you!

nvmheyer and others added 2 commits November 27, 2025 01:55
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>
@richgel999
Copy link
Contributor

Thank you! Will merge.

@richgel999
Copy link
Contributor

This has been merged into basisu v2.0 coming in Jan. 2026.

@NBickford-NV
Copy link
Author

Thank you Rich!

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.

3 participants