boostorg / move

Boost.org move module
http://boost.org/libs/move
Boost Software License 1.0
19 stars 55 forks source link

Compiler deprecation warnings with VS2019 Version 16.10 and boost/move headers #51

Closed pcaswell closed 4 months ago

pcaswell commented 1 year ago

Hello Boost Move, I've been in discussion with people at boost smart_ptr regarding an odd issue we see with VS2019. Here's the original discussion: https://github.com/boostorg/smart_ptr/issues/108

Here's my setup:

Here's a program that demonstrates the essence of the problem:

#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>

[[deprecated ("Since 1.0.0")]] int DeprecatedA()
{
    return 0;
}

int main()
{
    DeprecatedA();
    return 0;
}

This code should output compiler warnings (C4996) when compiled and it does providing I do not compile with these options: -external:W0 -external:I"C:/ThirdParty/v3.0.0/boost-1.77.0/include/boost-1_77". When these options are specified then the above program compiles without warning despite the deprecated function not being part of boost. If I comment out the #include <boost/make_shared.hpp> line then the compiler outputs deprecation errors as expected.

Further investigation showed that commenting out warning 4996 in boost/move/detail/config_begin.h fixes the problem. Also enclosing the move headers in /boost/smart_ptr/make_shared_object.hpp (as follows) also fixes the problem.

#pragma warning(push)
#include <boost/move/core.hpp>
#include <boost/move/utility_core.hpp>
#pragma warning(pop)

Fundamentally I think this is a Microsoft Compiler issue (that they've said they won't fix in VS2019). The code works as expected on Centos with GCC 11.3.0. However it does seem that something in the boost move headers is causing the compiler to get confused. If the issue is something to do with the move headers then can it be fixed across the board and not only for the inclusion of boost/make_shared.hpp as I've done above ?? The product I'm working on makes extensive use of boost - I just happened to notice this issue with the inclusion of that header.

Any help, thoughts and/or suggestions would be appreciated. Paul

igaztanaga commented 4 months ago

Many thanks for the report, in current code there is no need to disable that warning, so I removed that.