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

GCC error with fallback uint128_t #2777

Closed
moiwi opened this issue Feb 17, 2022 · 2 comments
Closed

GCC error with fallback uint128_t #2777

moiwi opened this issue Feb 17, 2022 · 2 comments

Comments

@moiwi
Copy link
Contributor

moiwi commented Feb 17, 2022

With ce93a66 I get this error with 32 bit GCC 8.1:

t:\fmt.org\fmt\format.h: In instantiation of 'To fmt::v8::detail::bit_cast(const From&) [with To = fmt::v8::detail::uint128_t; From = long double]':
t:\fmt.org\fmt\format-inl.h:261:36:   required from 'constexpr bool fmt::v8::detail::fp::assign(Float) [with Float = long double; typename std::enable_if<std::integral_constant<bool, (((sizeof (Float) == sizeof (unsigned int)) || (sizeof (Float) == (2 * sizeof (unsigned int)))) || (std::numeric_limits<_Tp>::digits == 64))>::value, int>::type <anonymous> = 0]'
t:\fmt.org\fmt\format-inl.h:245:66:   required from 'constexpr fmt::v8::detail::fp::fp(Float) [with Float = long double]'
t:\fmt.org\fmt\format-inl.h:2264:30:   required from 'int fmt::v8::detail::format_float(T, int, fmt::v8::detail::float_specs, fmt::v8::detail::buffer<char>&) [with T = long double]'
../../fmt.org/src/format.cc:111:64:   required from here
t:\fmt.org\fmt\format.h:293:28: error: static assertion failed: size mismatch
   static_assert(sizeof(To) == sizeof(From), "size mismatch");
                 ~~~~~~~~~~~^~~~~~~~~~~~~~~
t:\fmt.org\fmt\format.h:298:14: warning: 'void* memcpy(void*, const void*, size_t)' copying an object of non-trivial type 'class fmt::v8::detail::uint128_t' from an array of 'const long double' [-Wclass-memaccess]
   std::memcpy(&to, &from, sizeof(to));
   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from t:\fmt.org\fmt\format.h:50,
                 from t:\fmt.org\fmt\format-inl.h:29,
                 from ../../fmt.org/src/format.cc:8:
t:\fmt.org\fmt\core.h:393:7: note: 'class fmt::v8::detail::uint128_t' declared here
 class uint128_t {
       ^~~~~~~~~

(plus an initialization order warning:

t:\fmt.org\fmt\core.h: In constructor 'constexpr fmt::v8::detail::uint128_t::uint128_t(uint64_t)':
t:\fmt.org\fmt\core.h:395:17: warning: 'fmt::v8::detail::uint128_t::hi_' will be initialized after [-Wreorder]
   uint64_t lo_, hi_;
                 ^~~
t:\fmt.org\fmt\core.h:395:12: warning:   'uint64_t fmt::v8::detail::uint128_t::lo_' [-Wreorder]
   uint64_t lo_, hi_;
            ^~~
t:\fmt.org\fmt\core.h:399:13: warning:   when initialized here [-Wreorder]
   constexpr uint128_t(uint64_t value = 0) : hi_(0), lo_(value) {}
             ^~~~~~~~~

)

Originally posted by @moiwi in #2771 (comment)

@vitaut
Copy link
Contributor

vitaut commented Feb 18, 2022

Oops. Looks like long double is 96-bit in this configuration. Here's a tentative workaround: 532a69a.

@moiwi
Copy link
Contributor Author

moiwi commented Feb 18, 2022

Yes, works for me. Thank you!

@vitaut vitaut closed this as completed Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants