abseil-cpp icon indicating copy to clipboard operation
abseil-cpp copied to clipboard

abseil's absl::is_trivially_copy_assignable uses deprecated, broken compiler builtin

Open royjacobson opened this issue 3 years ago • 2 comments

As a side effect of implementing DR2171 for clang, we have discovered that absl::is_trivially_copy_assignable uses the __has_trivial_assign compiler builtin.

This compiler builtin has bad semantics when deleted functions are involved because clang considers them trivial for this purpose. Specifically it appears that MSVC stl delete the copy assignment operator for volatile& std::pair which causes abseil to assert when instantiating absl::Optional<std::pair<int, int>> with MSVC stl.

This has been discussed over at https://reviews.llvm.org/D127593. We might revert this change momentarily, but it would be helpful if abseil will stop using the __has_trivial... builtins.

Note that GCC uses the same 'deleted is trivial' semantics as clang, and that those builtins have been deprecated for quite some time: this is a discussion of the same issue from 2017: https://github.com/llvm/llvm-project/issues/33063

royjacobson avatar Jun 22 '22 20:06 royjacobson

On the Mozilla side: https://bugzilla.mozilla.org/show_bug.cgi?id=1779528 (firefox uses libwebrtc which uses abseil-cpp)

sylvestre avatar Jul 18 '22 12:07 sylvestre

In addition to __has_trivial_assign, abseil uses __has_trivial_copy and __has_trivial_constructor in type_traits.h which are also deprecated.

sseckler avatar Jul 21 '22 13:07 sseckler

https://github.com/abseil/abseil-cpp/pull/1289

keith avatar Oct 04 '22 17:10 keith