Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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] #1508

Closed
ryandesign opened this issue Apr 24, 2024 · 2 comments

Comments

@ryandesign
Copy link
Contributor

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");
                       ~~~~~~~ ^  ~~~~~~~~
@ampli
Copy link
Member

ampli commented Apr 24, 2024

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.

linas added a commit to linas/link-grammar that referenced this issue May 21, 2024
This fixes issue opencog#1508.
Also some minor style modernizations included.
@linas
Copy link
Member

linas commented May 21, 2024

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

@linas linas closed this as completed May 21, 2024
linas added a commit that referenced this issue May 25, 2024
Missed two asserts that should hve been done in #1533 #1508
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants