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: unassignedclangb...@nondot.org
          Reporter: malts...@gmail.com
                CC: llvm-bugs@lists.llvm.org, mclow.li...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to