Skip to content

GCC error with fallback uint128_t #2777

Description

@moiwi

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions