Skip to content

std::shared_ptr::unique() is deprecated in C++17 #208

@dirk-zimoch

Description

@dirk-zimoch

serverContext.cpp uses std::shared_ptr::unique() here

#define LEAK_CHECK(PTR, NAME) if((PTR) && !(PTR).unique()) { std::cerr<<"Leaking ServerContext " NAME " use_count="<<(PTR).use_count()<<"\n"<<show_referrers(PTR, false);}

and here
if(!wrapped.unique())

but that method is deprecated in c++17 and removed in C++20.

MSVC 2019 warns about this when using -Zc:__cplusplus -std:c++17:

src\server\serverContext.cpp(321): warning C4996: 'std::shared_ptr<epics::pvAccess::BlockingUDPTransport>::unique':
warning STL4016: std::shared_ptr::unique() is deprecated in C++17.
You can define _SILENCE_CXX17_SHARED_PTR_UNIQUE_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
to acknowledge that you have received this warning.

It can be silenced but that may only lead to problems later.

I have not seen a similar warning or error from gcc or clang, even when using -std:c++23.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions