Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: broken uint256_t conversion operator #3625

Merged
merged 4 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#ifdef __i386__
#include "barretenberg/common/serialize.hpp"
#include <concepts>

namespace numeric {

Expand Down Expand Up @@ -37,7 +38,7 @@ class alignas(32) uint128_t {
constexpr ~uint128_t() = default;
explicit constexpr operator bool() const { return static_cast<bool>(data[0]); };

template <typename T> explicit constexpr operator T() const { return static_cast<T>(data[0]); };
template <std::integral T> explicit constexpr operator T() const { return static_cast<T>(data[0]); };

[[nodiscard]] constexpr bool get_bit(uint64_t bit_index) const;
[[nodiscard]] constexpr uint64_t get_msb() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "../uint128/uint128.hpp"
#include "barretenberg/common/serialize.hpp"
#include "barretenberg/common/throw_or_abort.hpp"
#include <concepts>
#include <cstdint>
#include <iomanip>
#include <iostream>
Expand Down Expand Up @@ -91,7 +92,7 @@ class alignas(32) uint256_t {

explicit constexpr operator bool() const { return static_cast<bool>(data[0]); };

template <typename T> explicit constexpr operator T() const { return static_cast<T>(data[0]); };
template <std::integral T> explicit constexpr operator T() const { return static_cast<T>(data[0]); };

[[nodiscard]] constexpr bool get_bit(uint64_t bit_index) const;
[[nodiscard]] constexpr uint64_t get_msb() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ template <typename Builder> class BigFieldBase {
mask = (uint256_t(1) << mask_size) - 1;
// Choose the bit range
// Return instruction
return { .id = instruction_opcode, .arguments.element = Element(temp & mask) };
return { .id = instruction_opcode, .arguments.element = Element(static_cast<uint64_t>(temp & mask)) };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also see this same line in field.fuzzer.hpp; no need to change there too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it wasn't used, and we'll hit errors when we try to use it.


break;
case OPCODE::RANDOMSEED:
Expand Down