aws/aws-sdk-cpp

Visual Studio 2022 STD::Allocator Warning Treated as Error

AMZN-Gene opened this issue · 5 comments

Describe the bug

Compiling AWS SDK 1.11.344 results in compiler warnings due to using deprecated std::allocator member variables in C++17

Expected Behavior

Build should succeed

Current Behavior

D:\3p-package-source\package-system\AWSNativeSDK\temp\src\src\aws-cpp-sdk-core\include\aws\core\utils\memory\stl\AWSAll
ocator.h(65,9): error C2220: the following warning is treated as an error [D:\3p-package-source\package-system\AWSNativ
eSDK\temp\build\Debug_Shared\src\aws-cpp-sdk-core\aws-cpp-sdk-core.vcxproj]
D:\3p-package-source\package-system\AWSNativeSDK\temp\src\src\aws-cpp-sdk-core\include\aws\core\utils\memory\stl\AWSAll
ocator.h(65,9): warning C4996: 'std::allocator<_Ty>::pointer': warning STL4010: Various members of std::allocator are d
eprecated in C++17. Use std::allocator_traits instead of accessing these members directly. You can define _SILENCE_CXX1
7_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to suppress this warning. [D:\3p
-package-source\package-system\AWSNativeSDK\temp\build\Debug_Shared\src\aws-cpp-sdk-core\aws-cpp-sdk-core.vcxproj]
D:\3p-package-source\package-system\AWSNativeSDK\temp\src\src\aws-cpp-sdk-core\include\aws\core\utils\memory\stl\AWSAll
ocator.h(72,25): warning C4996: 'std::allocator<_Ty>::pointer': warning STL4010: Various members of std::allocator are
deprecated in C++17. Use std::allocator_traits instead of accessing these members directly. You can define _SILENCE_CXX
17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to suppress this warning. [D:\3
p-package-source\package-system\AWSNativeSDK\temp\build\Debug_Shared\src\aws-cpp-sdk-core\aws-cpp-sdk-core.vcxproj]
D:\3p-package-source\package-system\AWSNativeSDK\temp\src\src\aws-cpp-sdk-core\include\aws\core\utils\memory\stl\AWSAll
ocator.h(65,9): warning C4996: 'std::allocator<T>::pointer': warning STL4010: Various members of std::allocator are dep
recated in C++17. Use std::allocator_traits instead of accessing these members directly. You can define _SILENCE_CXX17_
OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to suppress this warning. [D:\3p-p
ackage-source\package-system\AWSNativeSDK\temp\build\Debug_Shared\src\aws-cpp-sdk-core\aws-cpp-sdk-core.vcxproj]

Reproduction Steps

  1. Build AWS SDK 1.11.344 for Windows using C++17 with latest VS 2022.
    MSVC 19.40.33811.0
    cmake 3.29
cmake -S %SRC_PATH% -B %BLD_PATH%\Debug_Shared ^
           -G "Visual Studio 17 2022" ^
           -A x64 ^
           -DTARGET_ARCH=WINDOWS ^
           -DCMAKE_CXX_STANDARD=17 ^
           -DCPP_STANDARD=17 ^
           -DBUILD_ONLY="access-management;bedrock-runtime;cognito-identity;cognito-idp;core;devicefarm;dynamodb;gamelift;identity-management;kinesis;lambda;queues;s3;sns;sqs;sts;transfer" ^
           -DENABLE_TESTING=OFF ^
           -DENABLE_RTTI=ON ^
           -DCUSTOM_MEMORY_MANAGEMENT=ON ^
           -DFORCE_SHARED_CRT=ON ^
           -DBUILD_SHARED_LIBS=ON ^
           -DCMAKE_BUILD_TYPE="Debug" ^
           -DCMAKE_INSTALL_BINDIR="bin" ^
           -DCMAKE_INSTALL_LIBDIR="lib" ^

Temporary Work Around

Temp workaround is to use -DAWS_SDK_WARNINGS_ARE_ERRORS=OFF

Additional Information/Context

No response

AWS CPP SDK version used

1.11.344

Compiler and Version used

Visual Studio 2022 MSVC 19.40.33811.0

Operating System and version

Windows 10 Enterprise

Thanks for pointing this out to us. Can you confirm if your suggested workaround works for you?

I see this when building on C++20 as well.

If I replace the code in aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSAllocator.h

before Base::pointer, after std::allocator_traits<Base>::pointer, then it works.

Thanks for pointing this out to us. Can you confirm if your suggested workaround works for you?

-DAWS_SDK_WARNINGS_ARE_ERRORS=OFF works.
Better solution is @laramiel fix (see patch)
AWSNativeSDK-1.11.344-windows.patch

I made a PR here to fix this

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.