Skip to content

Commit 278c00c

Browse files
committed
[libc++] [NFC] Test that correct value category is used in scoped_allocator_adaptor::construct
This patch fixes 2586. Just tests. NFC. Differential Revision: https://reviews.llvm.org/D63050
1 parent 596da62 commit 278c00c

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

libcxx/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,18 @@ struct F
111111

112112
bool F::constructed = false;
113113

114+
struct G
115+
{
116+
static bool constructed;
117+
118+
typedef std::allocator<G> allocator_type;
119+
120+
G(std::allocator_arg_t, allocator_type&&) { assert(false); }
121+
G(allocator_type&) { constructed = true; }
122+
};
123+
124+
bool G::constructed = false;
125+
114126
int main(int, char**)
115127
{
116128

@@ -185,6 +197,17 @@ int main(int, char**)
185197
assert(A3<F>::constructed);
186198
s->~S();
187199
}
200+
201+
// LWG 2586
202+
// Test that is_constructible uses an lvalue ref so the correct constructor
203+
// is picked.
204+
{
205+
std::scoped_allocator_adaptor<G::allocator_type> sa;
206+
G* ptr = sa.allocate(1);
207+
sa.construct(ptr);
208+
assert(G::constructed);
209+
sa.deallocate(ptr, 1);
210+
}
188211

189212
return 0;
190213
}

libcxx/www/cxx1z_status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ <h3>Library Working group Issues Status</h3>
308308
<tr><td><a href="https://wg21.link/LWG2582">2582</a></td><td>&sect;[res.on.functions]/2's prohibition against incomplete types shouldn't apply to type traits</td><td>Jacksonville</td><td>Complete</td></tr>
309309
<tr><td><a href="https://wg21.link/LWG2583">2583</a></td><td>There is no way to supply an allocator for <tt>basic_string(str, pos)</tt></td><td>Jacksonville</td><td>Complete</td></tr>
310310
<tr><td><a href="https://wg21.link/LWG2585">2585</a></td><td><tt>forward_list::resize(size_type, const value_type&amp;)</tt> effects incorrect</td><td>Jacksonville</td><td>Complete</td></tr>
311-
<tr><td><a href="https://wg21.link/LWG2586">2586</a></td><td>Wrong value category used in <tt>scoped_allocator_adaptor::construct()</tt></td><td>Jacksonville</td><td></td></tr>
311+
<tr><td><a href="https://wg21.link/LWG2586">2586</a></td><td>Wrong value category used in <tt>scoped_allocator_adaptor::construct()</tt></td><td>Jacksonville</td><td>Complete</td></tr>
312312
<tr><td><a href="https://wg21.link/LWG2590">2590</a></td><td>Aggregate initialization for <tt>std::array</tt></td><td>Jacksonville</td><td>Complete</td></tr>
313313
<tr><td></td><td></td><td></td><td></td></tr>
314314
<tr><td><a href="https://wg21.link/LWG2181">2181</a></td><td>Exceptions from seed sequence operations</td><td>Oulu</td><td>Complete</td></tr>

0 commit comments

Comments
 (0)