miniscript: comparison of integers of different signs #27381

issue fanquake openend this issue on March 31, 2023
  1. fanquake commented at 12:24 pm on March 31, 2023: member

    This is being emitted with GCC 10.2.1, in some CI jobs: i.e https://github.com/bitcoin/bitcoin/pull/25972/checks?check_run_id=12423693655, or https://github.com/bitcoin/bitcoin/pull/25972/checks?check_run_id=12423693651 (where we actually turn on all our warning flags with depends builds).

    0In file included from test/miniscript_tests.cpp:19:
    1./script/miniscript.h:1197:71: error: comparison of integers of different signs: 'typename iterator_traits<int *>::difference_type' (aka 'int') and 'const uint32_t' (aka 'const unsigned int') [-Werror,-Wsign-compare]
    2                    return std::count(subs.begin(), subs.end(), true) >= node.k;
    3                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~
    4test/miniscript_tests.cpp:346:34: note: in instantiation of function template specialization 'miniscript::Node<CPubKey>::IsSatisfiable<(lambda at test/miniscript_tests.cpp:346:48)>' requested here
    5        bool satisfiable = node->IsSatisfiable([](const Node&) { return true; });
    6                                 ^
    71 error generated.
    

    cc @darosior

  2. maflcko commented at 12:29 pm on March 31, 2023: member
    It should be fine to make the returned value of std::count unsigned.
  3. maflcko added the label Refactoring on Mar 31, 2023
  4. darosior commented at 12:30 pm on March 31, 2023: member
    I’m on it. I’ll check if there are other occurrences too, had quite a lot of them in #27255.
  5. fanquake closed this on Apr 2, 2023

  6. bitcoin locked this on Apr 1, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-03 07:12 UTC

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