Here is the source: src/cpp/testGenDataRow.cu
#include <string>
#include <variant>
#include <vector>
using DataRow = std::vector<std::variant<std::string, float, int>>;
int main()
{
DataRow dataRow;
dataRow.push_back("2");
dataRow.push_back(2);
dataRow.push_back(1.2f);
return 0;
}
Compile with nvcc src/cpp/testGenDataRow.cu -o testGen.o
, everything works fine
c++17 also works: nvcc -std=c++17 src/cpp/testGenDataRow.cu -o testGen.o
But when using c++20: nvcc -std=c++20 src/cpp/testGenDataRow.cu -o testGen.o
compile errors occurred
/home/username/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/variant(479): error: function "std::__detail::__variant::_Variadic_union<_First, _Rest...>::~_Variadic_union() [with _First=std::string, _Rest=<float, int>]" (declared at line 400) cannot be referenced -- it is a deleted function
~_Variant_storage()
^
detected during:
instantiation of "std::__detail::__variant::_Variant_storage<false, _Types...>::~_Variant_storage() [with _Types=<std::string, float, int>]" at line 88 of /home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_construct.h
implicit generation of "std::__detail::__variant::_Copy_ctor_base<<unnamed>, _Types...>::~_Copy_ctor_base() noexcept [with <unnamed>=false, _Types=<std::string, float, int>]" at line 88 of /home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_construct.h
instantiation of class "std::__detail::__variant::_Copy_ctor_base<<unnamed>, _Types...> [with <unnamed>=false, _Types=<std::string, float, int>]" at line 88 of /home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_construct.h
implicit generation of "std::__detail::__variant::_Move_ctor_base<<unnamed>, _Types...>::~_Move_ctor_base() noexcept [with <unnamed>=false, _Types=<std::string, float, int>]" at line 88 of /home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_construct.h
instantiation of class "std::__detail::__variant::_Move_ctor_base<<unnamed>, _Types...> [with <unnamed>=false, _Types=<std::string, float, int>]" at line 88 of /home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_construct.h
[ 8 instantiation contexts not shown ]
instantiation of "void std::_Destroy(_Tp *) [with _Tp=std::variant<std::string, float, int>]" at line 163 of /home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_construct.h
instantiation of "void std::_Destroy_aux<<unnamed>>::__destroy(_ForwardIterator, _ForwardIterator) [with <unnamed>=false, _ForwardIterator=std::variant<std::string, float, int> *]" at line 193 of /home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_construct.h
instantiation of "void std::_Destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator=std::variant<std::string, float, int> *]" at line 850 of /home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/alloc_traits.h
instantiation of "void std::_Destroy(_ForwardIterator, _ForwardIterator, std::allocator<_Tp> &) [with _ForwardIterator=std::variant<std::string, float, int> *, _Tp=std::variant<std::string, float, int>]" at line 731 of /home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_vector.h
instantiation of "std::vector<_Tp, _Alloc>::~vector() noexcept [with _Tp=std::variant<std::string, float, int>, _Alloc=std::allocator<std::variant<std::string, float, int>>]" at line 9 of src/cpp/testGenDataRow.cu
/home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/variant(455): error: function "std::__detail::__variant::_Variadic_union<_First, _Rest...>::~_Variadic_union() [with _First=std::string, _Rest=<float, int>]" (declared at line 400) cannot be referenced -- it is a deleted function
{ }
^
detected during:
instantiation of "std::__detail::__variant::_Variant_storage<false, _Types...>::_Variant_storage() [with _Types=<std::string, float, int>]" at line 599
instantiation of class "std::__detail::__variant::_Copy_ctor_base<<unnamed>, _Types...> [with <unnamed>=false, _Types=<std::string, float, int>]" at line 599
instantiation of "std::__detail::__variant::_Move_ctor_base<<unnamed>, _Types...>::_Move_ctor_base(std::__detail::__variant::_Move_ctor_base<<unnamed>, _Types...> &&) [with <unnamed>=false, _Types=<std::string, float, int>]" at line 97 of /home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_construct.h
instantiation of class "std::__detail::__variant::_Copy_assign_base<<unnamed>, _Types...> [with <unnamed>=false, _Types=<std::string, float, int>]" at line 97 of /home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_construct.h
instantiation of class "std::__detail::__variant::_Move_assign_base<<unnamed>, _Types...> [with <unnamed>=false, _Types=<std::string, float, int>]" at line 97 of /home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_construct.h
instantiation of class "std::__detail::__variant::_Variant_base<_Types...> [with _Types=<std::string, float, int>]" at line 97 of /home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_construct.h
instantiation of class "std::variant<_Types...> [with _Types=<std::string, float, int>]" at line 97 of /home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_construct.h
instantiation of "auto std::construct_at(_Tp *, _Args &&...)->decltype((<expression>)) [with _Tp=std::variant<std::string, float, int>, _Args=<std::variant<std::string, float, int>>]" at line 518 of /home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/alloc_traits.h
instantiation of "void std::allocator_traits<std::allocator<_Tp>>::construct(std::allocator_traits<std::allocator<_Tp>>::allocator_type &, _Up *, _Args &&...) [with _Tp=std::variant<std::string, float, int>, _Up=std::variant<std::string, float, int>, _Args=<std::variant<std::string, float, int>>]" at line 118 of /home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/vector.tcc
instantiation of "std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args &&...) [with _Tp=std::variant<std::string, float, int>, _Alloc=std::allocator<std::variant<std::string, float, int>>, _Args=<std::variant<std::string, float, int>>]" at line 1294 of /home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_vector.h
instantiation of "void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type &&) [with _Tp=std::variant<std::string, float, int>, _Alloc=std::allocator<std::variant<std::string, float, int>>]" at line 10 of src/cpp/testGenDataRow.cu
/home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/variant(460): error: function "std::__detail::__variant::_Variadic_union<_First, _Rest...>::~_Variadic_union() [with _First=std::string, _Rest=<float, int>]" (declared at line 400) cannot be referenced -- it is a deleted function
: _M_u(in_place_index<_Np>, std::forward<_Args>(__args)...),
^
detected during:
instantiation of "std::__detail::__variant::_Variant_storage<false, _Types...>::_Variant_storage(std::in_place_index_t<_Np>, _Args &&...) [with _Types=<std::string, float, int>, _Np=0UL, _Args=<const char (&)[2]>]" at line 747
implicit generation of "std::__detail::__variant::_Copy_ctor_base<false, std::string, float, int>::_Copy_ctor_base(std::in_place_index_t<_Np>, _Args &&...) [with _Np=0UL, _Args=<const char (&)[2]>]" at line 747
instantiation of class "std::__detail::__variant::_Copy_ctor_base<<unnamed>, _Types...> [with <unnamed>=false, _Types=<std::string, float, int>]" at line 747
implicit generation of "std::__detail::__variant::_Move_ctor_base<false, std::string, float, int>::_Move_ctor_base(std::in_place_index_t<_Np>, _Args &&...) [with _Np=0UL, _Args=<const char (&)[2]>]" at line 747
instantiation of class "std::__detail::__variant::_Move_ctor_base<<unnamed>, _Types...> [with <unnamed>=false, _Types=<std::string, float, int>]" at line 747
[ 2 instantiation contexts not shown ]
implicit generation of "std::__detail::__variant::_Move_assign_base<false, std::string, float, int>::_Move_assign_base(std::in_place_index_t<_Np>, _Args &&...) [with _Np=0UL, _Args=<const char (&)[2]>]" at line 747
instantiation of class "std::__detail::__variant::_Move_assign_base<<unnamed>, _Types...> [with <unnamed>=false, _Types=<std::string, float, int>]" at line 747
instantiation of "std::__detail::__variant::_Variant_base<_Types...>::_Variant_base(std::in_place_index_t<_Np>, _Args &&...) [with _Types=<std::string, float, int>, _Np=0UL, _Args=<const char (&)[2]>]" at line 1447
instantiation of "std::variant<_Types...>::variant(std::in_place_index_t<_Np>, _Args &&...) [with _Types=<std::string, float, int>, _Np=0UL, _Args=<const char (&)[2]>, _Tp=std::string, <unnamed>=void]" at line 1420
instantiation of "std::variant<_Types...>::variant(_Tp &&) [with _Types=<std::string, float, int>, _Tp=const char (&)[2], <unnamed>=void, <unnamed>=void, _Tj=std::string, <unnamed>=void]" at line 10 of src/cpp/testGenDataRow.cu
/home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/variant(460): error: function "std::__detail::__variant::_Variadic_union<_First, _Rest...>::~_Variadic_union() [with _First=std::string, _Rest=<float, int>]" (declared at line 400) cannot be referenced -- it is a deleted function
: _M_u(in_place_index<_Np>, std::forward<_Args>(__args)...),
^
detected during:
instantiation of "std::__detail::__variant::_Variant_storage<false, _Types...>::_Variant_storage(std::in_place_index_t<_Np>, _Args &&...) [with _Types=<std::string, float, int>, _Np=2UL, _Args=<int>]" at line 747
implicit generation of "std::__detail::__variant::_Copy_ctor_base<false, std::string, float, int>::_Copy_ctor_base(std::in_place_index_t<_Np>, _Args &&...) [with _Np=2UL, _Args=<int>]" at line 747
instantiation of class "std::__detail::__variant::_Copy_ctor_base<<unnamed>, _Types...> [with <unnamed>=false, _Types=<std::string, float, int>]" at line 747
implicit generation of "std::__detail::__variant::_Move_ctor_base<false, std::string, float, int>::_Move_ctor_base(std::in_place_index_t<_Np>, _Args &&...) [with _Np=2UL, _Args=<int>]" at line 747
instantiation of class "std::__detail::__variant::_Move_ctor_base<<unnamed>, _Types...> [with <unnamed>=false, _Types=<std::string, float, int>]" at line 747
[ 2 instantiation contexts not shown ]
implicit generation of "std::__detail::__variant::_Move_assign_base<false, std::string, float, int>::_Move_assign_base(std::in_place_index_t<_Np>, _Args &&...) [with _Np=2UL, _Args=<int>]" at line 747
instantiation of class "std::__detail::__variant::_Move_assign_base<<unnamed>, _Types...> [with <unnamed>=false, _Types=<std::string, float, int>]" at line 747
instantiation of "std::__detail::__variant::_Variant_base<_Types...>::_Variant_base(std::in_place_index_t<_Np>, _Args &&...) [with _Types=<std::string, float, int>, _Np=2UL, _Args=<int>]" at line 1447
instantiation of "std::variant<_Types...>::variant(std::in_place_index_t<_Np>, _Args &&...) [with _Types=<std::string, float, int>, _Np=2UL, _Args=<int>, _Tp=int, <unnamed>=void]" at line 1420
instantiation of "std::variant<_Types...>::variant(_Tp &&) [with _Types=<std::string, float, int>, _Tp=int, <unnamed>=void, <unnamed>=void, _Tj=int, <unnamed>=void]" at line 11 of src/cpp/testGenDataRow.cu
/home/aqua/miniconda3/x86_64-conda-linux-gnu/include/c++/12.3.0/variant(460): error: function "std::__detail::__variant::_Variadic_union<_First, _Rest...>::~_Variadic_union() [with _First=std::string, _Rest=<float, int>]" (declared at line 400) cannot be referenced -- it is a deleted function
: _M_u(in_place_index<_Np>, std::forward<_Args>(__args)...),
^
detected during:
instantiation of "std::__detail::__variant::_Variant_storage<false, _Types...>::_Variant_storage(std::in_place_index_t<_Np>, _Args &&...) [with _Types=<std::string, float, int>, _Np=1UL, _Args=<float>]" at line 747
implicit generation of "std::__detail::__variant::_Copy_ctor_base<false, std::string, float, int>::_Copy_ctor_base(std::in_place_index_t<_Np>, _Args &&...) [with _Np=1UL, _Args=<float>]" at line 747
instantiation of class "std::__detail::__variant::_Copy_ctor_base<<unnamed>, _Types...> [with <unnamed>=false, _Types=<std::string, float, int>]" at line 747
implicit generation of "std::__detail::__variant::_Move_ctor_base<false, std::string, float, int>::_Move_ctor_base(std::in_place_index_t<_Np>, _Args &&...) [with _Np=1UL, _Args=<float>]" at line 747
instantiation of class "std::__detail::__variant::_Move_ctor_base<<unnamed>, _Types...> [with <unnamed>=false, _Types=<std::string, float, int>]" at line 747
[ 2 instantiation contexts not shown ]
implicit generation of "std::__detail::__variant::_Move_assign_base<false, std::string, float, int>::_Move_assign_base(std::in_place_index_t<_Np>, _Args &&...) [with _Np=1UL, _Args=<float>]" at line 747
instantiation of class "std::__detail::__variant::_Move_assign_base<<unnamed>, _Types...> [with <unnamed>=false, _Types=<std::string, float, int>]" at line 747
instantiation of "std::__detail::__variant::_Variant_base<_Types...>::_Variant_base(std::in_place_index_t<_Np>, _Args &&...) [with _Types=<std::string, float, int>, _Np=1UL, _Args=<float>]" at line 1447
instantiation of "std::variant<_Types...>::variant(std::in_place_index_t<_Np>, _Args &&...) [with _Types=<std::string, float, int>, _Np=1UL, _Args=<float>, _Tp=float, <unnamed>=void]" at line 1420
instantiation of "std::variant<_Types...>::variant(_Tp &&) [with _Types=<std::string, float, int>, _Tp=float, <unnamed>=void, <unnamed>=void, _Tj=float, <unnamed>=void]" at line 12 of src/cpp/testGenDataRow.cu
5 errors detected in the compilation of "src/cpp/testGenDataRow.cu".
System info
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Tue_Aug_15_22:02:13_PDT_2023
Cuda compilation tools, release 12.2, V12.2.140
Build cuda_12.2.r12.2/compiler.33191640_0
$ nvidia-smi
Sat Oct 21 09:55:14 2023
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.104.12 Driver Version: 535.104.12 CUDA Version: 12.2 |
|-----------------------------------------+----------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+======================+======================|
| 0 NVIDIA GeForce RTX 2060 On | 00000000:01:00.0 On | N/A |
| 0% 54C P2 31W / 175W | 1419MiB / 6144MiB | 2% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy