Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

std::allocator functions and typedefs deprecated in C++17 #1214

Closed
brycelelbach opened this issue Jun 30, 2020 · 4 comments · Fixed by #1223 or #1518
Closed

std::allocator functions and typedefs deprecated in C++17 #1214

brycelelbach opened this issue Jun 30, 2020 · 4 comments · Fixed by #1223 or #1518
Assignees
Labels
nvbug Has an associated internal NVIDIA NVBug.
Milestone

Comments

@brycelelbach
Copy link
Collaborator

With MSVC 2017:

C:/dvs/p4/build/sw/gpgpu/thrust\thrust/detail/allocator/allocator_traits.inl(87): error #1444-D: function "std::allocator<_Ty>::construct(_Objty *, _Types &&...) [with _Ty=vec2, _Objty=vec2, _Types=<>]"
C:/dvs/p4/build/sw/tools/win32/msvc/16.0.0/VC//include\xmemory0(939): here was declared deprecated ("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_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning.")
...

NVBug 200619442

@brycelelbach brycelelbach added the nvbug Has an associated internal NVIDIA NVBug. label Jun 30, 2020
@brycelelbach brycelelbach added this to the 1.9.10-1 milestone Jun 30, 2020
alliepiper added a commit to alliepiper/thrust that referenced this issue Jul 7, 2020
alliepiper added a commit to alliepiper/thrust that referenced this issue Jul 7, 2020
alliepiper added a commit to alliepiper/thrust that referenced this issue Jul 8, 2020
alliepiper added a commit that referenced this issue Jul 9, 2020
alliepiper added a commit that referenced this issue Jul 10, 2020
@alliepiper alliepiper changed the title std::allocator::construct is deprecated in C++17 std::allocator functions and typedefs deprecated in C++17 Jul 14, 2020
@alliepiper
Copy link
Collaborator

Reopening -- the typedefs on std::allocator were deprecated, too, and are still blocking this for QA.

@alliepiper alliepiper reopened this Jul 14, 2020
@alliepiper
Copy link
Collaborator

The root cause of the MSVC/C++17 std::allocator bugs is that CMake will apparently ignore any requested CUDA_STANDARD that it doesn't know how to handle. I've filed a bug about it here: https://gitlab.kitware.com/cmake/cmake/-/issues/20953.

We'll need to bump the CMake version to 3.18 (which is still in RC...) to get support for any C++17 targets.

Fortunately CMake is easy to install on most platforms and the release cycles are short, so we should see a full 3.18 soon. If anyone has issue upgrading in the meantime, let me know.

CMake downloads: https://cmake.org/download/
CMake apt repo instructions: https://apt.kitware.com/

alliepiper added a commit to alliepiper/thrust that referenced this issue Jul 15, 2020
Note that CMake won't support C++17 CUDA targets via the CUDA_STANDARD
property until CMake 3.18. Until this, C++17 must be enabled explicitly
by setting `--std=c++17` in CMAKE_CUDA_FLAGS.

Once CMake 3.18 is released this can be fixed.

- Address C++17 deprecated APIs in the allocator layers.

Fixes NVIDIA#1214

Bug 200619424
Bug 3043659
alliepiper added a commit to alliepiper/thrust that referenced this issue Jul 15, 2020
These affect files that aren't in the 1.9.10-1 branch.

- Enable /W3 on Windows to catch deprecation warnings.
- Enabled the `CUDA_STANDARD_REQUIRED` property.
- Replace std::result_of with std::invoke_result.

Fixes NVIDIA#1214

Bug 200619424
alliepiper added a commit to alliepiper/thrust that referenced this issue Jul 17, 2020
Note that CMake won't support C++17 CUDA targets via the CUDA_STANDARD
property until CMake 3.18. Until this, C++17 must be enabled explicitly
by setting `--std=c++17` in CMAKE_CUDA_FLAGS.

Once CMake 3.18 is released this can be fixed.

- Address C++17 deprecated APIs in the allocator layers.

Fixes NVIDIA#1214

Bug 200619424
Bug 3043659
brycelelbach pushed a commit that referenced this issue Jul 20, 2020
Note that CMake won't support C++17 CUDA targets via the CUDA_STANDARD
property until CMake 3.18. Until this, C++17 must be enabled explicitly
by setting `--std=c++17` in CMAKE_CUDA_FLAGS.

Once CMake 3.18 is released this can be fixed.

- Address C++17 deprecated APIs in the allocator layers.

Fixes #1214

Bug 200619424
Bug 3043659
brycelelbach pushed a commit that referenced this issue Jul 20, 2020
Note that CMake won't support C++17 CUDA targets via the CUDA_STANDARD
property until CMake 3.18. Until this, C++17 must be enabled explicitly
by setting `--std=c++17` in CMAKE_CUDA_FLAGS.

Once CMake 3.18 is released this can be fixed.

- Address C++17 deprecated APIs in the allocator layers.

Fixes #1214

Bug 200619424
Bug 3043659
alliepiper added a commit that referenced this issue Jul 24, 2020
Note that CMake won't support C++17 CUDA targets via the CUDA_STANDARD
property until CMake 3.18. Until this, C++17 must be enabled explicitly
by setting `--std=c++17` in CMAKE_CUDA_FLAGS.

Once CMake 3.18 is released this can be fixed.

- Address C++17 deprecated APIs in the allocator layers.

Fixes #1214

Bug 200619424
Bug 3043659
alliepiper added a commit that referenced this issue Jul 24, 2020
These affect files that aren't in the 1.9.10-1 branch.

- Enable /W3 on Windows to catch deprecation warnings.
- Enabled the `CUDA_STANDARD_REQUIRED` property.
- Replace std::result_of with std::invoke_result.

Fixes #1214

Bug 200619424
@gevtushenko
Copy link
Collaborator

gevtushenko commented Jun 22, 2021

The problem seems to appear on fresh VS install (16.10.2):

C:/Users/evtus/Documents/GitHub/nvidia/thrust\thrust/detail/allocator/allocator_traits.h(143): error C2220: the following warning is treated as an error
C:/Users/evtus/Documents/GitHub/nvidia/thrust\thrust/detail/allocator/allocator_traits.h(143): warning C4996: 'std::allocator<int>::is_always_equal': 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_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning.
C:/Users/evtus/Documents/GitHub/nvidia/thrust\thrust/detail/type_traits.h(455): note: see reference to class template instantiation 'thrust::detail::allocator_traits_detail::nested_is_always_equal<std::allocator<int>>' being compiled
C:/Users/evtus/Documents/GitHub/nvidia/thrust\thrust/detail/allocator/allocator_traits.inl(67): note: see reference to class template instantiation 'thrust::detail::eval_if<true,thrust::detail::allocator_traits_detail::nested_is_always_equal<std::allocator<int>>,thrust::detail::is_empty<std::allocator<int>>>' being compiled
C:/Users/evtus/Documents/GitHub/nvidia/thrust\thrust/detail/contiguous_storage.h(42): note: see reference to class template instantiation 'thrust::detail::allocator_traits<Alloc>' being compiled
        with
        [
            Alloc=std::allocator<int>
        ]
C:/Users/evtus/Documents/GitHub/nvidia/thrust\thrust/detail/vector_base.h(47): note: see reference to class template instantiation 'thrust::detail::contiguous_storage<T,Alloc>' being compiled
        with
        [
            T=int,
            Alloc=std::allocator<int>
        ]
C:/Users/evtus/Documents/GitHub/nvidia/thrust\thrust/host_vector.h(52): note: see reference to class template instantiation 'thrust::detail::vector_base<T,Alloc>' being compiled
        with
        [
            T=int,
            Alloc=std::allocator<int>
        ]
C:\Users\evtus\Documents\GitHub\nvidia\thrust\testing\copy_n.cu(23): note: see reference to class template instantiation 'thrust::host_vector<int,std::allocator<int>>' being compiled

Using the following modification leads to successful compilation:

#if THRUST_CPP_DIALECT >= 2017
  using is_always_equal = typename is_empty<allocator_type>;
#else
  using is_always_equal = typename allocator_traits_detail::nested_is_always_equal<allocator_type>;
#endif

But I can't verify the fix for older standards due to the following issue.

@gevtushenko gevtushenko reopened this Jun 22, 2021
@alliepiper
Copy link
Collaborator

NVBug 200723050 is related.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
nvbug Has an associated internal NVIDIA NVBug.
Projects
None yet
3 participants