[Bug libstdc++/56383] New: error with multiple enable_shared_from_this base classes

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Feb 18 18:54:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56383

             Bug #: 56383
           Summary: error with multiple enable_shared_from_this base
                    classes
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: redi@gcc.gnu.org
        ReportedBy: redi@gcc.gnu.org


This should compile and exit normally:

#include <memory>
#include <cstdlib>

struct A : std::enable_shared_from_this<A>
{
    void* a() { return shared_from_this().get(); }
};

struct B : std::enable_shared_from_this<B>
{
};

struct D : A, B
{
};

int main()
{
    auto d = std::make_shared<D>();
    try
    {
        d->a();
        std::abort();
    }
    catch (std::bad_weak_ptr const&)
    { }
}

I have a fix in mind, but it can wait for post-4.8.0



More information about the Gcc-bugs mailing list