Merge bitcoin/bitcoin#33600: refactor: Construct g_verify_flag_names on first use

faa9d10c84 refactor: Construct g_verify_flag_names on first use (MarcoFalke)

Pull request description:

  The current usage of the `g_verify_flag_names` map seems fine and I can not see a static initialization order fiasco here.

  However, it seems brittle to hope this remains the case in the future. Also, it triggers a msan false-positive in the fuzz CI task. (C.f https://github.com/bitcoin-core/qa-assets/actions/runs/18352815555/job/52413137315?pr=241#step:7:5245)

  So just apply the "Construct on first use" idiom.

ACKs for top commit:
  kevkevinpal:
    ACK [faa9d10](faa9d10c84)
  ajtowns:
    ACK faa9d10c84
  janb84:
    lgtm ACK faa9d10c84
  stickies-v:
    ACK faa9d10c84

Tree-SHA512: 6685dfc91c99a8245722e07fac99a7a6d58586c30964be7ccd74a176dfbf00c6255c8594621e2909640763924f51d3efd4ce65ed65eaeeb1d05c2fd01fe63604
This commit is contained in:
merge-script
2025-10-23 05:55:55 -04:00
3 changed files with 30 additions and 26 deletions

View File

@@ -50,7 +50,7 @@ typedef std::vector<unsigned char> valtype;
static CFeeRate g_dust{DUST_RELAY_TX_FEE};
static bool g_bare_multi{DEFAULT_PERMIT_BAREMULTISIG};
static const std::map<std::string, script_verify_flag_name>& mapFlagNames = g_verify_flag_names;
static const std::map<std::string, script_verify_flag_name>& mapFlagNames = ScriptFlagNamesToEnum();
script_verify_flags ParseScriptFlags(std::string strFlags)
{