Skip to content

<memory>: error C2694 when calling make_shared on class with throwing destructor #1733

Description

C:\Temp>type meow.cpp
#include <memory>
using namespace std;

struct A {
  A() {}
  ~A() noexcept(false) {}
};

int main() { auto a = make_shared<A>(); }
C:\Temp>cl /EHsc /nologo /W4 meow.cpp
meow.cpp
D:\GitHub\STL\out\build\x86\out\inc\memory(2015): error C2694: 'std::_Ref_count_obj2<_Ty>::~_Ref_count_obj2(void)': overriding virtual function has less restrictive exception specification than base class virtual member function 'std::_Ref_count_base::~_Ref_count_base(void) noexcept'
        with
        [
            _Ty=A
        ]
D:\GitHub\STL\out\build\x86\out\inc\memory(2015): note: see declaration of 'std::_Ref_count_obj2<_Ty>::~_Ref_count_obj2'
        with
        [
            _Ty=A
        ]
D:\GitHub\STL\out\build\x86\out\inc\memory(1072): note: see declaration of 'std::_Ref_count_base::~_Ref_count_base'
D:\GitHub\STL\out\build\x86\out\inc\memory(2730): note: see reference to class template instantiation 'std::_Ref_count_obj2<_Ty>' being compiled
        with
        [
            _Ty=A
        ]
meow.cpp(9): note: see reference to function template instantiation 'std::shared_ptr<A> std::make_shared<A,>(void)' being compiled

Originally reported as DevCom-1306429 and Microsoft-internal VSO-1265102 / AB#1265102 .

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

    bugSomething isn't workingfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions