Enabling -Wextra leads to several warnings inside span-lite since gcc 10.2, for example (https://godbolt.org/z/7GrYsM):
<source>:1084:25: warning: comparison of unsigned expression in '>= 0' is always true [-Wtype-limits]
1084 | span_EXPECTS( 0 <= idx && idx < size() );
|
In many places, an index of size_type is checked to be not negative, which results in this warning if the size_type is an unsigned type (which is the default). If size_type is configured to be signed, the check 0 <= idx is of course reasonable. Not quite sure what the best approach would be. Write a helper template function is_negative that checks the type for signedness first and only then performs the check maybe? Or disable the warning entirely, but maybe it could be useful for other cases?
Enabling
-Wextra
leads to several warnings inside span-lite since gcc 10.2, for example (https://godbolt.org/z/7GrYsM):In many places, an index of
size_type
is checked to be not negative, which results in this warning if thesize_type
is an unsigned type (which is the default). Ifsize_type
is configured to be signed, the check0 <= idx
is of course reasonable. Not quite sure what the best approach would be. Write a helper template functionis_negative
that checks the type for signedness first and only then performs the check maybe? Or disable the warning entirely, but maybe it could be useful for other cases?