Commit 25331ba
Fix ill-formed req::Allocator rebind (#9640)
Summary:
Given an Allocator A<T> and some cv-unqualified object type U, let B = A::template rebind<U>::other. The C++ standard stipulates[1] that in this case, B::template rebind<T>::other must be A for any U. HPHP::req::Allocator does not satisfy this constraint at present, but this does not fail compilation at all times because the constraint is inconsistently enforced by different standard library implementations.
Consider the simplified reproducer in https://godbolt.org/z/9b19z4Yz8. If using libstdc++, the code won't compile with any libstdc++ > 12, because alloc_traits.h enforces this requirement.
If using libc++, the code will compile, but uncomment the std::vector variable definition in main() and it will trigger libc++'s own check for this constraint and fail.
So, make req::Allocator::rebind conform to the standard by having it return the original allocator in this case.
[1] https://en.cppreference.com/w/cpp/named_req/Allocator.html
Pull Request resolved: #9640
Reviewed By: ricklavoie
Differential Revision: D83148440
fbshipit-source-id: 63aa13ee82c67d377d373693fd0e3a7b04c1350a1 parent 8493090 commit 25331ba
1 file changed
+12
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
181 | 185 | | |
182 | 186 | | |
183 | 187 | | |
| |||
275 | 279 | | |
276 | 280 | | |
277 | 281 | | |
278 | | - | |
| |||
0 commit comments