[PATCH] D96536: Make sure some types are indeed trivially_copyable per llvm::is_trivially_copyable

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 8 08:13:41 PST 2021


arichardson added inline comments.


================
Comment at: llvm/unittests/Support/TypeTraitsTest.cpp:113
+  TrivialityTester<std::function<int()>, false, false>();
+  TrivialityTester<std::pair<int, bool>, true, true>();
+  TrivialityTester<llvm::unique_function<int()>, false, false>();
----------------
This causes a build failure on FreeBSD12.2:
```
[1196/1577] Building CXX object unittests/Support/CMakeFiles/SupportTests.dir/TypeTraitsTest.cpp.o
FAILED: unittests/Support/CMakeFiles/SupportTests.dir/TypeTraitsTest.cpp.o
/usr/local/bin/clang++11 -DGTEST_HAS_RTTI=0 -DGTEST_HAS_TR1_TUPLE=0 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iunittests/Support -I/exports/users/alr48/sources/upstream-llvm-project/llvm/unittests/Support -Iinclude -I/exports/users/alr48/sources/upstream-llvm-project/llvm/include -I/exports/users/alr48/sources/upstream-llvm-project/llvm/utils/unittest/googletest/include -I/exports/users/alr48/sources/upstream-llvm-project/llvm/utils/unittest/googlemock/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -O3   -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -fno-exceptions -fno-rtti -UNDEBUG -Wno-suggest-override -std=c++14 -MD -MT unittests/Support/CMakeFiles/SupportTests.dir/TypeTraitsTest.cpp.o -MF unittests/Support/CMakeFiles/SupportTests.dir/TypeTraitsTest.cpp.o.d -o unittests/Support/CMakeFiles/SupportTests.dir/TypeTraitsTest.cpp.o -c /exports/users/alr48/sources/upstream-llvm-project/llvm/unittests/Support/TypeTraitsTest.cpp
/exports/users/alr48/sources/upstream-llvm-project/llvm/unittests/Support/TypeTraitsTest.cpp:28:3: error: static_assert failed due to requirement 'llvm::is_trivially_copy_constructible<std::__1::pair<int, bool>>::value == true' "Mismatch in expected trivial copy construction!"
  static_assert(llvm::is_trivially_copy_constructible<T>::value ==
  ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/exports/users/alr48/sources/upstream-llvm-project/llvm/unittests/Support/TypeTraitsTest.cpp:113:3: note: in instantiation of function template specialization '(anonymous namespace)::triviality::TrivialityTester<std::__1::pair<int, bool>, true, true>' requested here
  TrivialityTester<std::pair<int, bool>, true, true>();
  ^
/exports/users/alr48/sources/upstream-llvm-project/llvm/unittests/Support/TypeTraitsTest.cpp:31:3: error: static_assert failed due to requirement 'llvm::is_trivially_move_constructible<std::__1::pair<int, bool>>::value == true' "Mismatch in expected trivial move construction!"
  static_assert(llvm::is_trivially_move_constructible<T>::value ==
  ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/exports/users/alr48/sources/upstream-llvm-project/llvm/unittests/Support/TypeTraitsTest.cpp:37:3: error: static_assert failed due to requirement 'std::is_trivially_copy_constructible<std::__1::pair<int, bool>>::value == true' "Mismatch in expected trivial copy construction!"
  static_assert(std::is_trivially_copy_constructible<T>::value ==
  ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/exports/users/alr48/sources/upstream-llvm-project/llvm/unittests/Support/TypeTraitsTest.cpp:40:3: error: static_assert failed due to requirement 'std::is_trivially_move_constructible<std::__1::pair<int, bool>>::value == true' "Mismatch in expected trivial move construction!"
  static_assert(std::is_trivially_move_constructible<T>::value ==
  ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 errors generated.
```

I'm not 100% what version of libc++ is being used as the system libc++, but clang is 10.0.1 so it's probably libc++ from that same git revision (git at github.com:llvm/llvm-project.git llvmorg-10.0.1-0-gef32c611aa2)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96536



More information about the llvm-commits mailing list