Skip to content

Commit a504100

Browse files
committed
Fix variable type
`uint64_t` was causing `idx` to be cast to `uint64_t`, thus reinterpreting the sign.
1 parent 2010916 commit a504100

File tree

1 file changed

+1
-1
lines changed
  • lib/node_modules/@stdlib/ndarray/base/wrap-index/src

1 file changed

+1
-1
lines changed

lib/node_modules/@stdlib/ndarray/base/wrap-index/src/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* // returns 2
3434
*/
3535
int64_t stdlib_ndarray_wrap_index( int64_t idx, int64_t max ) {
36-
uint64_t mp1 = max + 1; // `uint64_t` to guard against overflow
36+
int64_t mp1 = max + 1; // WARNING: possibility of overflow (although, in practice, `max` should never be that large)
3737
if ( idx < 0 ) {
3838
idx += mp1; // slight optimization to avoid modulo arithmetic when |idx| <= max+1
3939
if ( idx < 0 ) {

0 commit comments

Comments
 (0)