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

Comparison of unsigned size_t with 0 creates unreachable code #5

Closed
bact opened this issue Oct 20, 2016 · 1 comment
Closed

Comparison of unsigned size_t with 0 creates unreachable code #5

bact opened this issue Oct 20, 2016 · 1 comment

Comments

@bact
Copy link

bact commented Oct 20, 2016

What happened

Under
Apple LLVM version 8.0.0 (clang-800.0.38)
Target: x86_64-apple-darwin15.6.0

make put this warning

trietool.c:128:13: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
if (res < 0)

1 warning generated.

Possible cause

  • res is size_t, returned from iconv()
  • the intention is to checked if there is error occur or not during iconv() call, if there is iconv() will return -1
  • size_t [which is unsigned] < 0 is always false

Proposed fix

128c128
<     if (res < 0)

---
>     if (res == (size_t) -1)
@bact
Copy link
Author

bact commented Oct 20, 2016

Sorry. Duplicate of Issue #3

Close.

@bact bact closed this as completed Oct 20, 2016
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

1 participant