[PATCH] D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable

James Player via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 18 11:35:27 PST 2020


jplayer-nv added a comment.

> any idea why this only fails for MSVC? It'd be good to understand more why this didn't trip up other builds so we can avoid those sort of divergences in the future, perhaps.

Likely related to a recent change to `std::pair` in MSVC.  They added the following:

  pair& operator=(const volatile pair&) = delete;

This seems to implicitly delete the default version of the copy assignment.  Although, they do have a non-trivial template which serves as the copy assignment in place the the deleted default one.  Not sure whether MS intended to delete the default copy assignment here, but this is valid C++ code as far as I can tell.

The test cases I added to OptionalTest.cpp should replicate these conditions for both the copy assignment and the copy constructor.



================
Comment at: llvm/include/llvm/ADT/Optional.h:36-38
+template <typename T, bool = is_trivially_copyable<T>::value
+                          &&std::is_trivially_copy_constructible<T>::value
+                              &&std::is_trivially_copy_assignable<T>::value>
----------------
dblaikie wrote:
> Could you run this through clang-format?
This was already run through clang-format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93510



More information about the llvm-commits mailing list