Non-boolean const value in && expression. #20693

issue kallewoof opened this issue on December 18, 2020
  1. kallewoof commented at 6:01 AM on December 18, 2020: member

    Chances are high people know about this already, but this code really does look broken:

    wallet/scriptpubkeyman.cpp: In member function ‘virtual bool LegacyScriptPubKeyMan::Upgrade(int, bilingual_str&)’:
    wallet/scriptpubkeyman.cpp:456:55: warning: logical ‘and’ applied to non-boolean constant [-Wlogical-op]
      456 |     if (m_storage.CanSupportFeature(FEATURE_HD_SPLIT) && CHDChain::VERSION_HD_CHAIN_SPLIT) {
          |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

    Especially considering we do things like this:

        newHdChain.nVersion = m_storage.CanSupportFeature(FEATURE_HD_SPLIT) ? CHDChain::VERSION_HD_CHAIN_SPLIT : CHDChain::VERSION_HD_BASE;
    

    which will trigger the above if case for both cases, since both are non-zero.

    Maybe this code is just dead and thus this doesn't matter?

  2. kallewoof added the label Bug on Dec 18, 2020
  3. sipa commented at 6:08 AM on December 18, 2020: member

    I think this was fixed in #19986.

  4. kristapsk commented at 6:08 AM on December 18, 2020: contributor

    Duplicate of #19912, fixed by #19986. No? I don't see code above on a current master.

  5. MarcoFalke commented at 6:10 AM on December 18, 2020: member

    Is this still an issue with a recent version of Bitcoin Core? If yes, what are the steps to reproduce?

  6. MarcoFalke closed this on Dec 18, 2020

  7. kallewoof commented at 6:53 AM on December 18, 2020: member

    Aha! I saw this in a working branch which was not on latest master. Thanks!

  8. DrahtBot locked this on Feb 15, 2022

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: 2026-04-14 18:14 UTC

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