facebook / folly

An open-source C++ library developed and used at Facebook.
https://groups.google.com/forum/?fromgroups#!forum/facebook-folly
Apache License 2.0
28.36k stars 5.56k forks source link

error: static assertion failed: Big endian requires a redesigned table #1834

Open barracuda156 opened 2 years ago

barracuda156 commented 2 years ago

Another error on 10.6.8 Rosetta with gcc12:

/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_folly/folly/work/folly-v2022.08.01.00/folly/detail/base64_detail/Base64SWAR.cpp: In function 'uint32_t folly::detail::base64_detail::{anonymous}::base64DecodeSWARMainLoop(const char*&, const char*, char*&)':
/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_folly/folly/work/folly-v2022.08.01.00/folly/detail/base64_detail/Base64SWAR.cpp:101:14: error: static assertion failed: Big endian requires a redesigned table
  101 |       folly::kIsLittleEndian, "Big endian requires a redesigned table");
      |       ~~~~~~~^~~~~~~~~~~~~~~
barracuda156 commented 2 years ago

Source code leading to the error:

template <bool isURL>
std::uint32_t base64DecodeSWARMainLoop(
    const char*& f, const char* l, char*& o) noexcept {
  static_assert(
      folly::kIsLittleEndian, "Big endian requires a redesigned table");

  std::uint32_t errorAccumulator = 0;

  while (l - f > 4) {
    std::uint32_t r = //
        kBase64SwarDecodeTable<isURL>[0][atAsU8(f, 0)] |
        kBase64SwarDecodeTable<isURL>[1][atAsU8(f, 1)] |
        kBase64SwarDecodeTable<isURL>[2][atAsU8(f, 2)] |
        kBase64SwarDecodeTable<isURL>[3][atAsU8(f, 3)];

    errorAccumulator |= r;
    std::memcpy(o, &r, sizeof(r));

    f += 4;
    o += 3;
  }

  return errorAccumulator;
}
barracuda156 commented 2 years ago

Looks like Big Endian have been broken forever with folly: https://bytemeta.vip/repo/facebook/folly/issues/1445

barracuda156 commented 3 months ago

Now Big-endian is broken by https://github.com/facebook/folly/commit/1110819343455b5f698e8d01a951b9da1b3b9c5a commit.