[Bug libstdc++/89477] Incorrect CTAD deduction guides for set and multiset
arthur.j.odwyer at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Feb 28 04:55:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89477
--- Comment #4 from Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> ---
libstdc++ passes all my test cases now except this one:
```
// https://godbolt.org/z/kvh9Ih
#include <set>
std::set<int> s;
std::set t(s, std::allocator<long>());
```
The issue is that we humans can logically deduce t's Allocator parameter as
"the same as s's Allocator parameter", but due to an implementation detail, the
compiler is also trying to deduce t's Allocator parameter as
std::allocator<long>, and so it deduces conflicting types and fails deduction.
This test case could be made to work if you changed
https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/stl_set.h#L124
from
typedef _Alloc allocator_type;
to
typedef typename __identity<_Alloc>::type allocator_type;
or whatever libstdc++'s equivalent of __identity is.
MSVC's `set` already effectively does this, by inheriting its `allocator_type`
typedef from a base class. I don't know whether the paper standard has a
definite interpretation one way or the other; it might be open to
interpretation, or it might even say that MSVC is wrong in this case.
(Logically, I think MSVC *should* be right.)
Perhaps a new bugzilla issue should be opened for this one.
More information about the Gcc-bugs
mailing list