https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69293
Bug ID: 69293 Summary: scoped_allocator_adaptor::construct calls wrong function Product: gcc Version: 5.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: forever14 at bk dot ru Target Milestone: --- There is a bug in scoped_allocator_adaptor::construct. Consider following code: #include <iostream> #include <memory> #include <scoped_allocator> struct use_arg { template<typename Alloc> use_arg(int i, Alloc&) { std::cout << i << " in use_arg()\n"; } }; namespace std { template <typename A> struct uses_allocator<use_arg, A>: true_type {}; } // namespace std void test_scoped() { std::scoped_allocator_adaptor<std::allocator<use_arg>> sa; auto p = sa.allocate(1); sa.construct(p, 4); sa.destroy(p); sa.deallocate(p, 1); } int main() { test_scoped(); } There will not be compilation error, but should be, since: template <class T, class... Args> void construct(T* p, Args&&... args); 9 (9.1) Effects: ... (9.3) — Otherwise, if uses_allocator<T, inner_allocator_type>::value is true and is_construct- ible<T, Args..., inner_allocator_type>::value is true, calls OUTERMOST_ALLOC_- TRAITS(*this):: construct(OUTERMOST (*this), p, std::forward<Args>(args)..., inner_allocator()). (9.4) — Otherwise, the program is ill-formed. [ Note: An error will result if uses_allocator evaluates to true but the specific constructor does not take an allocator. This definition prevents a silent failure to pass an inner allocator to a contained element. — end note ] In code, is_constructible<T, Args..., inner_allocator_type>::value is false, since use_arg receives Alloc by reference, but there is no test for this case in libstdc++.