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 for FMT_MODULE not compiling on GCC #3605

Merged
merged 4 commits into from
Aug 25, 2023
Merged
Changes from 3 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
7 changes: 4 additions & 3 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,15 +369,16 @@ class uint128_fallback {
private:
uint64_t lo_, hi_;

friend uint128_fallback umul128(uint64_t x, uint64_t y) noexcept;

public:
constexpr uint128_fallback(uint64_t hi, uint64_t lo) : lo_(lo), hi_(hi) {}
constexpr uint128_fallback(uint64_t value = 0) : lo_(value), hi_(0) {}

constexpr uint64_t high() const noexcept { return hi_; }
constexpr uint64_t low() const noexcept { return lo_; }

uint64_t& high() { return hi_; }
uint64_t& low() { return lo_; }

template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
constexpr explicit operator T() const {
return static_cast<T>(lo_);
Expand Down Expand Up @@ -1489,7 +1490,7 @@ inline uint128_fallback umul128(uint64_t x, uint64_t y) noexcept {
return {static_cast<uint64_t>(p >> 64), static_cast<uint64_t>(p)};
#elif defined(_MSC_VER) && defined(_M_X64)
auto result = uint128_fallback();
result.lo_ = _umul128(x, y, &result.hi_);
result.low() = _umul128(x, y, &result.high());
return result;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's change this to something like:

auto hi = uint64_t();
auto lo = _umul128(x, y, &hi);
return {hi, lo};

and remove the new accessors.

#else
const uint64_t mask = static_cast<uint64_t>(max_value<uint32_t>());
Expand Down