Skip to content

Segfault on allocator destruction with virtual dtor #2

Description

@jwt27

Hi, thanks for this great header, I still use this because of its allocator support. However I just now discovered that it chokes when given an allocator that has a base with virtual destructor.

The following code consistently segfaults upon calling the allocator dtor in templated_call_move_and_destroy():

#include <function.h>

struct A { virtual ~A() { } };

template <typename T = std::byte>
struct Alloc : A
{
    T* allocate(std::size_t) { return nullptr; }
    void deallocate(T*) { }
};

int main()
{
    func::function<int()> f { std::allocator_arg, Alloc<> { }, [] { return 0; } };
    return f();
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions