Depending on the signedness of length_t type we may either get warnings comparison of unsigned expression in ‘>= 0’ being always true or do insufficient checking by not checking if index is not negative.
Hide the index checking behind a macro that check the index properly.
This hides warnings like the following (I used #define GLM_FORCE_SIZE_T_LENGTH):
In file included from /usr/include/c++/13/cassert:44,
from ../subprojects/glm-1.0.0/glm/gtc/.././ext/../detail/setup.hpp:3,
from ../subprojects/glm-1.0.0/glm/gtc/.././ext/../detail/qualifier.hpp:3,
from ../subprojects/glm-1.0.0/glm/gtc/.././ext/../detail/type_vec4.hpp:6,
from ../subprojects/glm-1.0.0/glm/gtc/.././ext/../detail/type_mat4x4.hpp:6,
from ../subprojects/glm-1.0.0/glm/gtc/.././ext/matrix_double4x4.hpp:5,
from ../subprojects/glm-1.0.0/glm/gtc/../mat4x4.hpp:5,
from ../subprojects/glm-1.0.0/glm/gtc/matrix_transform.hpp:24,
from ../bin/next/main.cc:19:
../subprojects/glm-1.0.0/glm/gtc/.././ext/../detail/type_vec4.inl: In instantiation of ‘constexpr T& glm::vec<4, T, Q>::operator[](length_type) [with T = float; glm::qualifier Q = glm::packed_highp; length_type = long unsigned int]’:
../subprojects/glm-1.0.0/glm/gtc/../ext/matrix_clip_space.inl:7:12: required from ‘glm::mat<4, 4, T, glm::packed_highp> glm::ortho(T, T, T, T) [with T = float]’
../bin/next/main.cc:643:34: required from here
../subprojects/glm-1.0.0/glm/gtc/.././ext/../detail/type_vec4.inl:481:26: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
481 | assert(i >= 0 && i < this->length());
| ~~^~~~
../subprojects/glm-1.0.0/glm/gtc/.././ext/../detail/type_vec4.inl: In instantiation of ‘constexpr const T& glm::vec<4, T, Q>::operator[](length_type) const [with T = float; glm::qualifier Q = glm::packed_highp; length_type = long unsigned int]’:
../subprojects/glm-1.0.0/glm/gtc/.././ext/../detail/type_mat4x4.inl:561:50: required from ‘constexpr typename glm::mat<4, 4, T, Q>::col_type glm::operator*(const mat<4, 4, T, Q>&, const typename mat<4, 4, T, Q>::row_type&) [with T = float; qualifier Q = glm::packed_highp; typename mat<4, 4, T, Q>::col_type = vec<4, float, glm::packed_highp>; typename mat<4, 4, T, Q>::row_type = vec<4, float, glm::packed_highp>]’
../bin/next/main.cc:700:32: required from here
../subprojects/glm-1.0.0/glm/gtc/.././ext/../detail/type_vec4.inl:499:26: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
499 | assert(i >= 0 && i < this->length());
| ~~^~~~
Depending on the signedness of length_t type we may either get warnings comparison of unsigned expression in ‘>= 0’ being always true or do insufficient checking by not checking if index is not negative.
Hide the index checking behind a macro that check the index properly.
This hides warnings like the following (I used
#define GLM_FORCE_SIZE_T_LENGTH
):