Merge bitcoin/bitcoin#37007: refactor: Add missing explicit instantiations of function templates
What changed, and why it matters
This is a build-fix change, not a security fix. It adds explicit template instantiations for two internal functions used when computing Bitcoin transaction signatures. Without these, newer Clang compilers could fail to link the program because the functions were being used across multiple source files but only implicitly created in one. The change ensures the functions are definitely generated at compile time so the linker can find them. There is no vulnerability being patched here.
No security action required. Treat as a normal build-system/portability fix. Ensure CI includes Clang 24 builds to catch similar ODR/linkage issues in the future.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit adds explicit template instantiations for SignatureHashSchnorr<CTransaction>, SignatureHashSchnorr<CMutableTransaction>, SignatureHash<CTransaction>, and SignatureHash<CMutableTransaction> in src/script/interpreter.cpp. These function templates are defined in that translation unit but are also referenced from other translation units. Relying on implicit instantiation is not guaranteed by the C++ standard, and Clang 24’s new default -fmodule-local-hints behavior exposed this by causing link failures. The patch is purely a correctness/portability build fix; it does not alter program logic, function signatures, or runtime behavior.
Changed components
src/script/interpreter.cppInspect captured patch +8 / −0
### src/script/interpreter.cpp
@@ -1575,6 +1575,10 @@ bool SignatureHashSchnorr(uint256& hash_out, ScriptExecutionData& execdata, cons
return true;
}
+// explicit instantiation
+template bool SignatureHashSchnorr<CTransaction>(uint256&, ScriptExecutionData&, const CTransaction&, uint32_t, uint8_t, SigVersion, const PrecomputedTransactionData&, MissingDataBehavior);
+template bool SignatureHashSchnorr<CMutableTransaction>(uint256&, ScriptExecutionData&, const CMutableTransaction&, uint32_t, uint8_t, SigVersion, const PrecomputedTransactionData&, MissingDataBehavior);
+
int SigHashCache::CacheIndex(int32_t hash_type) const noexcept
{
// Note that we do not distinguish between BASE and WITNESS_V0 to determine the cache index,
@@ -1682,6 +1686,10 @@ uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn
return ss.GetHash();
}
+// explicit instantiation
+template uint256 SignatureHash<CTransaction>(const CScript&, const CTransaction&, unsigned int, int32_t, const CAmount&, SigVersion, const PrecomputedTransactionData*, SigHashCache*);
+template uint256 SignatureHash<CMutableTransaction>(const CScript&, const CMutableTransaction&, unsigned int, int32_t, const CAmount&, SigVersion, const PrecomputedTransactionData*, SigHashCache*);
+
template <class T>
bool GenericTransactionSignatureChecker<T>::VerifyECDSASignature(const std::vector<unsigned char>& vchSig, const CPubKey& pubkey, const uint256& sighash) const
{Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.