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: comparison is always false due to limited range of data type [-Wtype-limits] #100

Open
JonasBreuling opened this issue Jun 23, 2021 · 0 comments

Comments

@JonasBreuling
Copy link

On windows compiling the example

// indicators_issue.cpp

#include <indicators/progress_bar.hpp>

int main()
{
    int n = 100;

    indicators::ProgressBar pbar{
        indicators::option::MaxProgress{n},
    };

    for (int i = 0; i < n; ++i) {
        pbar.tick();
    }

    return 0;
}

compiling with gcc.exe (MinGW-W64 x86_64-posix-seh, built by Brecht Sanders) 10.3.0 I get the following annoying warnings:

In file included from C:/project/build/_deps/indicators_git-src/include/indicators/details/stream_helper.hpp:5,
                 from C:/project/build/_deps/indicators_git-src/include/indicators/progress_bar.hpp:5,
                 from C:\project\examples\indicators_issue.cpp:1:
C:/project/build/_deps/indicators_git-src/include/indicators/display_width.hpp: In function 'int unicode::details::mk_wcwidth(wchar_t)':
C:/project/build/_deps/indicators_git-src/include/indicators/display_width.hpp:201:57: warning: comparison is always false due to limited range of data type [-Wtype-limits]
  201 |                (ucs >= 0xffe0 && ucs <= 0xffe6) || (ucs >= 0x20000 && ucs <= 0x2fffd) ||
      |                                                     ~~~~^~~~~~~~~~
C:/project/build/_deps/indicators_git-src/include/indicators/display_width.hpp:201:75: warning: comparison is always true due to limited range of data type [-Wtype-limits]
  201 |                (ucs >= 0xffe0 && ucs <= 0xffe6) || (ucs >= 0x20000 && ucs <= 0x2fffd) ||
      |                                                                       ~~~~^~~~~~~~~~
C:/project/build/_deps/indicators_git-src/include/indicators/display_width.hpp:202:21: warning: comparison is always false due to limited range of data type [-Wtype-limits]
  202 |                (ucs >= 0x30000 && ucs <= 0x3fffd)));
      |                 ~~~~^~~~~~~~~~
C:/project/build/_deps/indicators_git-src/include/indicators/display_width.hpp:202:39: warning: comparison is always true due to limited range of data type [-Wtype-limits]
  202 |                (ucs >= 0x30000 && ucs <= 0x3fffd)));

Can these comparisons be removed?

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