[PATCH] D127593: [clang] Fix trivially copyable for copy constructor and copy assignment operator

Stephan Bergmann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 21 01:40:58 PDT 2022


sberg added a comment.

In D127593#3598020 <https://reviews.llvm.org/D127593#3598020>, @royjacobson wrote:

> Is it possible to check how often PDFium uses `__has_trivial_assign`? Depending on how large this breakage is we might need to revert and proceed more carefully..

The setup is a bit convoluted:  I ran into this when building LibreOffice with clang-cl on Windows.  LibreOffice builds a bundled PDFium (where it obtained the PDFium source tarball, including PDFium's bundled `third-party/abseil-cpp`, with a recipe documented at https://git.libreoffice.org/core/+/71b952340726190d1f178ef0dadfa89677f2c1dd/external/pdfium/README#6).  That PDFium in turn contains a bundled `third-party/abseil-cpp`, whose `absl/meta/type_traits.h` defines an `absl::is_trivially_copy_assignable` struct that is implemented via `__has_trivial_assign`, but then in its implementation also does a `static_assert` to verify that its behavior (based on `__has_trivial_assign`) matches the behavior of std::is_trivially_copy_assignable` (which is based on `__is_trivially_assignable`).  And that `static_assert` started to fail now with clang-cl on Windows against the MSVC standard library:

  In file included from C:/lo-clang/core/workdir/UnpackedTarball/pdfium/core/fxge/win32/cgdi_plus_ext.cpp:19:
  In file included from C:/lo-clang/core/workdir/UnpackedTarball/pdfium\core/fxcrt/fx_string.h:14:
  In file included from C:/lo-clang/core/workdir/UnpackedTarball/pdfium\core/fxcrt/bytestring.h:23:
  In file included from C:/lo-clang/core/workdir/UnpackedTarball/pdfium\core/fxcrt/string_view_template.h:18:
  In file included from C:/lo-clang/core/workdir/UnpackedTarball/pdfium\third_party/abseil-cpp/absl/types/optional.h:39:
  In file included from C:/lo-clang/core/workdir/UnpackedTarball/pdfium/third_party/abseil-cpp\absl/utility/utility.h:51:
  C:/lo-clang/core/workdir/UnpackedTarball/pdfium/third_party/abseil-cpp\absl/meta/type_traits.h(501,3): error: static_assert failed due to requirement 'compliant || std::is_trivially_copy_assignable<std::pair<unsigned long long, unsigned long long>>::value' "Not compliant with std::is_trivially_copy_assignable; Standard: false, Implementation: true"
    static_assert(compliant || std::is_trivially_copy_assignable<T>::value,
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  C:/lo-clang/core/workdir/UnpackedTarball/pdfium/third_party/abseil-cpp\absl/types/internal/optional.h(175,21): note: in instantiation of template class 'absl::is_trivially_copy_assignable<std::pair<unsigned long long, unsigned long long>>' requested here
                absl::is_trivially_copy_assignable<typename std::remove_cv<
                      ^
  C:/lo-clang/core/workdir/UnpackedTarball/pdfium\third_party/abseil-cpp/absl/types/optional.h(119,45): note: in instantiation of default argument for 'optional_data<std::pair<unsigned long long, unsigned long long>>' required here
  class optional : private optional_internal::optional_data<T>,
                                              ^~~~~~~~~~~~~~~~
  C:/lo-clang/core/workdir/UnpackedTarball/pdfium/core/fxge/win32/cgdi_plus_ext.cpp(384,43): note: in instantiation of template class 'absl::optional<std::pair<unsigned long long, unsigned long long>>' requested here
  absl::optional<std::pair<size_t, size_t>> IsSmallTriangle(
                                            ^

Both the PDFium tarball bundled by LibreOffice, and the `third-party/abseil` in turn bundled in that PDFium tarball, may be a bit dated, but I checked that PDFium's recent main branch https://pdfium.googlesource.com/pdfium/+/2c495300230ed67f87302716c8b262a146ae26af/core/fxge/win32/cgdi_plus_ext.cpp#375 still uses `absl::optional<std::pair<size_t, size_t>>`, and Abseil's recent master branch https://github.com/abseil/abseil-cpp/blob/42f22a28401c952f1fc5942231c7fdac80811bf5/absl/meta/type_traits.h#L264 definition of `absl::is_trivially_copy_assignable` still works as described above.

In general, there's still a handful of `__has_trivial_*` calls across Abseil's recent master branch `absl/meta/type_traits.h`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127593/new/

https://reviews.llvm.org/D127593



More information about the cfe-commits mailing list