[llvm-bugs] [Bug 49332] New: Default constructors of node-based containers don't construct allocators
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Feb 23 08:41:40 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=49332
Bug ID: 49332
Summary: Default constructors of node-based containers don't
construct allocators
Product: libc++
Version: 11.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: maltsevm at gmail.com
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
Consider the following code:
https://godbolt.org/z/Tn73Me
#include <forward_list>
#include <list>
#include <vector>
#include <deque>
#include <set>
#include <unordered_set>
#include <stdio.h>
int n_alloc = 0;
struct alloc : public std::allocator<char> {
alloc() { n_alloc++; };
};
int main(void)
{
std::vector<char, alloc> c1;
printf("n_alloc: %d\n", n_alloc);
std::deque<char, alloc> c2;
printf("n_alloc: %d\n", n_alloc);
std::forward_list<char, alloc> c3;
printf("n_alloc: %d\n", n_alloc);
std::list<char, alloc> c4;
printf("n_alloc: %d\n", n_alloc);
std::set<char, std::less<char>, alloc> c5;
printf("n_alloc: %d\n", n_alloc);
std::unordered_set<char, std::hash<char>, std::equal_to<char>, alloc> c6;
printf("n_alloc: %d\n", n_alloc);
}
In [forwardlist.overview], the default constructor is specified as follows:
forward_list() : forward_list(Allocator()) { }
Similarly for other containers.
So, the expected output of the above program is:
1
2
3
4
5
6
But with libc++ (recent trunk version) the output is:
1
2
2
2
2
2
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210223/8201b3be/attachment.html>
More information about the llvm-bugs
mailing list