Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revise std::vector uninit-mem hacks under libc++ #1912

Closed
wants to merge 1 commit into from

Conversation

yfeldblum
Copy link
Contributor

Summary:
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, 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.

Closes: #1867.

Differential Revision: D42459219

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D42459219

Summary:
Pull Request resolved: facebook#1912
Closes: facebook#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: 379b86055601e5cc166a4d3364ab8d10be86f001
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D42459219

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in f32f2ef.

facebook-github-bot pushed a commit to facebook/hhvm that referenced this pull request Jan 14, 2023
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
@yfeldblum yfeldblum deleted the export-D42459219 branch January 25, 2023 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

error: no template named '__vector_base' in namespace 'std'
2 participants