`<scoped_allocator>`, `<xpolymorphic_allocator.h>`: Pre-C++20 overload set of `construct` might be incorrect
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
Describe the bug
This program is well-formed in C++17 (but ill-formed since C++20 due to WG21-P0591), because the overload set of construct was specially designed for std::pair (N4659 [mem.poly.allocator.mem], cppreference).
#include <cstddef>
#include <memory_resource>
#include <type_traits>
#include <utility>
int main()
{
std::pair<int, int> pr{};
std::pmr::polymorphic_allocator<std::byte> pa{};
pa.construct<int, int>(&pr);
}
However, MSVC STL always implements the C++20 overload set of construct, and hence rejects this program in C++17 mode (Godbolt link).
scoped_allocator_adaptor::construct has exactly the same issue.
The issue has been present even before implementing WG21-P0591 (#1668). I'm not sure whether this is a bug or an intentional design.
Additional context
LWG-3677 may be related to this if we want consistent behaviors in C++17 & C++20 modes.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the C++17 reproducer and inspect the linked overloads in stl/inc/xpolymorphic_allocator.h and stl/inc/scoped_allocator. Compare their behavior with N4659, the cppreference description, and LWG-3677; done means the intended C++17 and C++20 behavior is established and verified for both allocator types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100