deallocate() function in allocator marked as not used


In a custom allocator, the IDE marks the deallocate function (but not allocate) as never used:

template<typename T>
class e_allocator {
    using value_type = T;
    using pointer = value_type *;
    using difference_type = typename std::pointer_traits<pointer>::difference_type;
    using size_type = std::make_unsigned_t<difference_type>;

    pointer allocate(size_type n) {
        return static_cast<pointer>(::operator new(n * sizeof(value_type),

    void deallocate(pointer p, size_type n) {
        // volatile is required here to defeat the optimizer
        std::fill_n(static_cast<volatile pointer>(p), n, 0);
        ::operator delete(p);

void foo() { std::vector<int, e_allocator<int> > v; }

Is there a way to suppress the warning?


1 comment

Hi! Yes, you can disable or suppress the "Unused global declaration" inspection:

More details:

Also I've created, feel free to comment or upvote in order to get updates. See if you are not familiar with YouTrack.


Please sign in to leave a comment.