From 0864e441a8ad1fa7938a2660726922d190eded84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Fri, 21 Nov 2025 10:01:41 +0100 Subject: [PATCH] Add explicit implementations of assignment operators These help GCC compiler not to put the uint256 values on stack. --- include/intx/intx.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/intx/intx.hpp b/include/intx/intx.hpp index eb53d119..c455f8b1 100644 --- a/include/intx/intx.hpp +++ b/include/intx/intx.hpp @@ -923,6 +923,24 @@ struct uint return static_cast(words_[0]); } + uint& operator=(uint64_t v) noexcept { + words_[0] = v; + for (size_t i = 1; i < num_words; ++i) + words_[i] = 0; + return *this; + } + + template + constexpr uint& operator=(const uint& x) noexcept + requires(M <= N) + { + for (size_t i = 0; i < uint::num_words; ++i) + words_[i] = x[i]; + for (size_t i = uint::num_words; i < num_words; ++i) + words_[i] = 0; + return *this; + } + friend constexpr uint operator+(const uint& x, const uint& y) noexcept { return addc(x, y).value;