opencog / link-grammar

The CMU Link Grammar natural language parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

warning: result of comparison of constant 18446744073709551615 with expression of type 'uint16_t' (aka 'unsigned short') is always true [-Wtautological-constant-out-of-range-compare]

ryandesign opened this issue · comments

These warnings appear when compiling with clang on macOS 14:

post-process/post-process.c:386:39: warning: result of comparison of constant 18446744073709551615 with expression of type 'uint16_t' (aka 'unsigned short') is always true [-Wtautological-constant-out-of-range-compare]
                assert(sublinkage->link_array[i].lw != SIZE_MAX, "Missing word in link");
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~


post-process/post-process.c:395:39: warning: result of comparison of constant 18446744073709551615 with expression of type 'uint16_t' (aka 'unsigned short') is always true [-Wtautological-constant-out-of-range-compare]
                assert(sublinkage->link_array[j].lw != SIZE_MAX, "Missing word in link");
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~


post-process/post-process.c:521:43: warning: result of comparison of constant 18446744073709551615 with expression of type 'uint16_t' (aka 'unsigned short') is always true [-Wtautological-constant-out-of-range-compare]
                assert (sublinkage->link_array[link].lw != SIZE_MAX, "Missing word in link");
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~


post-process/post-process.c:720:43: warning: result of comparison of constant 18446744073709551615 with expression of type 'uint16_t' (aka 'unsigned short') is always true [-Wtautological-constant-out-of-range-compare]
                assert (sublinkage->link_array[link].lw != SIZE_MAX, "Missing word in link");
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~


post-process/post-process.c:818:43: warning: result of comparison of constant 18446744073709551615 with expression of type 'uint16_t' (aka 'unsigned short') is always true [-Wtautological-constant-out-of-range-compare]
                assert (sublinkage->link_array[link].lw != SIZE_MAX, "Missing word in link");
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~


post-process/post-process.c:1020:36: warning: result of comparison of constant 18446744073709551615 with expression of type 'uint16_t' (aka 'unsigned short') is always true [-Wtautological-constant-out-of-range-compare]
                assert(linkage->link_array[i].lw != SIZE_MAX, "Missing word in link");
                       ~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~


print/print.c:365:25: warning: result of comparison of constant 18446744073709551615 with expression of type 'uint16_t' (aka 'unsigned short') is always true [-Wtautological-constant-out-of-range-compare]
                assert (ppla[link].lw != SIZE_MAX, "Missing word in link");
                        ~~~~~~~~~~~~~ ^  ~~~~~~~~


print/print.c:438:18: warning: result of comparison of constant 18446744073709551615 with expression of type 'uint16_t' (aka 'unsigned short') is always true [-Wtautological-constant-out-of-range-compare]
	mv -f $depbase.Tpo $depbase.Plo
                assert(lnk->lw != SIZE_MAX, "Missing word in link");
                       ~~~~~~~ ^  ~~~~~~~~

The code to set lw or rw (that were once size_t) to SIZE_MAX has been removed long ago.

Possible solutions:

  1. In partial_init_linkage(), memset with 1 and change the assert() calls accordingly..
  2. Just remove these() assert calls.

Thanks! Fixed in #1533. I just removed the asserts. Seemed easier that way