[Bug libstdc++/69293] scoped_allocator_adaptor::construct calls wrong function
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Jan 15 15:25:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69293
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to ForEveR from comment #0)
> 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++.
There doesn't need to be a check for that case, because if the
is_constructible<T, allocator_arg_t, Alloc, Args...> case is false then we will
try to construct as T(Args..., Alloc), and so if that is not constructible
then we get an error, i.e. it's ill-formed. We don't need to test
is_constructible, we can just attempt the cosntruction.
The bug is in the standard: it says that the actual construction is done as
T(Args..., Alloc&) which is not the same as the is_constructible test, so it's
possible for the is_constructible test to fail but for the actual construction
to succeed. That should not be possible.
I can add a static assertion to the __uses_alloc<true, ...> partial
specialization, as that will improve the diagnostics anyway, and cause this
example to be ill-formed.
More information about the Gcc-bugs
mailing list