]> gitweb.factorcode.org Git - factor.git/commit
vm: Fix C++ warning for comparing a signed to less-than 0.
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 15 Dec 2021 06:26:07 +0000 (00:26 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 15 Dec 2021 06:34:15 +0000 (00:34 -0600)
commitd34f4dfb1cbe870152b60d41bcbb5195f318de0a
tree70370e8ab8e0c065fe470def582b7caa922aaa0f
parent55891de5f3ee425d2c563999642b30b9f61463b3
vm: Fix C++ warning for comparing a signed to less-than 0.

Still a bit more duplication than I would like.

Found with:

c++ --version
c++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Warning:

vm/bignum.cpp: In member function ‘factor::bignum* factor::factor_vm::cell_to_bignum(factor::cell)’:
vm/bignum.cpp:332:11: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
  332 |     if (n < (type) 0 && n == (type) - 1)                              \
      |         ~~^~~~~~~~~~
vm/bignum.cpp:361:1: note: in expansion of macro ‘FOO_TO_BIGNUM’
  361 | FOO_TO_BIGNUM(cell, cell, fixnum, cell)
      | ^~~~~~~~~~~~~
vm/bignum.cpp:336:29: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
  336 |           ((negative_p = (n < (type) 0)) ? ((type)(-(stype) n)) : n); \
      |                           ~~^~~~~~~~~~
vm/bignum.cpp:361:1: note: in expansion of macro ‘FOO_TO_BIGNUM’
  361 | FOO_TO_BIGNUM(cell, cell, fixnum, cell)
      | ^~~~~~~~~~~~~
vm/bignum.cpp: In member function ‘factor::bignum* factor::factor_vm::ulong_long_to_bignum(uint64_t)’:
vm/bignum.cpp:332:11: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
  332 |     if (n < (type) 0 && n == (type) - 1)                              \
      |         ~~^~~~~~~~~~
vm/bignum.cpp:364:1: note: in expansion of macro ‘FOO_TO_BIGNUM’
  364 | FOO_TO_BIGNUM(ulong_long, uint64_t, int64_t, uint64_t)
      | ^~~~~~~~~~~~~
vm/bignum.cpp:336:29: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
  336 |           ((negative_p = (n < (type) 0)) ? ((type)(-(stype) n)) : n); \
      |                           ~~^~~~~~~~~~
vm/bignum.cpp:364:1: note: in expansion of macro ‘FOO_TO_BIGNUM’
  364 | FOO_TO_BIGNUM(ulong_long, uint64_t, int64_t, uint64_t)
      | ^~~~~~~~~~~~~
vm/bignum.cpp