Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revise std::vector uninit-mem hacks under libc++ (#1912)
Summary: X-link: facebook/folly#1912 Closes: facebook/folly#1867 The `std::__vector_base` class in libc++ is removed in libc++ 15 (llvm/llvm-project@b82da8b). So the two current implementations of the hacks - the implementation for libc++ 14 and the implementation for earlier libc++ - both fail. Even with libc++ 14, which retains `std::__vector_base`, Xcode 14 fails to compile the hacks: ``` In file included from folly/memory/test/UninitializedMemoryHacksODR.cpp:17: folly/memory/UninitializedMemoryHacks.h:461:1: error: conversion from 'std::__vector_base<char, std::allocator<char>>::pointer std::__vector_base<char, std::allocator<char>>::*' to 'char *std::vector<char>::*' is not allowed in a converted constant expression FOLLY_DECLARE_VECTOR_RESIZE_WITHOUT_INIT(char) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ folly/memory/UninitializedMemoryHacks.h:327:7: note: expanded from macro 'FOLLY_DECLARE_VECTOR_RESIZE_WITHOUT_INIT' &std::vector<TYPE>::__end_, \ ^~~~~~~~~~~~~~~~~~~~~~~~~~ ... ``` Since libc++ is unlikely to change the internal layout of `std::vector` on a cadence which is too frequent for folly - any material change would be an ABI break -, we can use a layout struct rather than a template instance for the hacks and have it work for a range of versions of libc++ and Xcode. Reviewed By: simpkins, swolchok Differential Revision: D42459219 fbshipit-source-id: e23ef383869681b5c81e4301114020b9089c7461
- Loading branch information