Fix -Wsign-compare compiler warning #151

pull hebasto wants to merge 1 commits into bitcoin-core:master from hebasto:250204-wsign changing 1 files +1 −1
  1. hebasto commented at 7:06 pm on February 4, 2025: member

    Fixes https://github.com/bitcoin/bitcoin/pull/30975#issuecomment-2634356140:

    … then found another issue:

    0/home/runner/work/_temp/src/ipc/libmultiprocess/src/mp/gen.cpp:633:26: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
    1  633 |     for (size_t i = 4; i < argc; ++i) {
    2      |                        ~ ^ ~~~~
    31 error generated.
    

    This is the only warning when all default Bitcoin Core flags are applied.

  2. Fix `-Wsign-compare` compiler warning 7452ddd1ee
  3. hebasto force-pushed on Feb 4, 2025
  4. hebasto renamed this:
    Fix `-Wsign` compiler warning
    Fix `-Wsign-compare` compiler warning
    on Feb 4, 2025
  5. in src/mp/gen.cpp:634 in 7452ddd1ee
    629@@ -630,7 +630,7 @@ int main(int argc, char** argv)
    630     } else {
    631         throw std::runtime_error(std::string("Failed to open src_prefix prefix directory: ") + argv[1]);
    632     }
    633-    for (size_t i = 4; i < argc; ++i) {
    634+    for (size_t i = 4; i < static_cast<size_t>(argc); ++i) {
    635         KJ_IF_MAYBE(dir, fs->getRoot().tryOpenSubdir(cwd.evalNative(argv[i]))) {
    


    ryanofsky commented at 7:51 pm on February 4, 2025:

    In commit “Fix -Wsign-compare compiler warning” (7452ddd1ee11557de935af821782e9babc7036f5)

    Is switching size_t on this line to int enough to fix the problem? It would seem better to avoid this error by using the same type consistently and avoiding the need to cast.


    ryanofsky commented at 4:17 am on February 5, 2025:

    re: https://github.com/chaincodelabs/libmultiprocess/pull/151#discussion_r1941803268

    Went ahead and made this change in #152 but did not confirm it fixes the warning (since I wasn’t seeing the warning). If not, can use the fix here instead.


    hebasto commented at 8:37 am on February 5, 2025:
    I can confirm that the commit from https://github.com/chaincodelabs/libmultiprocess/pull/152 fixed the warning.
  6. ryanofsky referenced this in commit 9558ceb0d4 on Feb 5, 2025
  7. hebasto closed this on Feb 5, 2025

  8. hebasto deleted the branch on Feb 5, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/libmultiprocess. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-12-04 19:30 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me