GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — CUDA < 12.4.1 bug affects use of openPMD-api in C++20 projects · Issue #1720 · openPMD/openPMD-api

CUDA < 12.4.1 bug affects use of openPMD-api in C++20 projects #1720

New issue
Copy link
New issue
Copy link
Closed
#1807
Closed
CUDA < 12.4.1 bug affects use of openPMD-api in C++20 projects#1720
#1807
Copy link
Assignees
franzpoeschel
Labels
buginstallthird partythird party libraries that are shipped and/or linkedthird party libraries that are shipped and/or linkedwontfixworkaround

Description

@franzpoeschel
franzpoeschel
opened on Feb 20, 2025
Issue body actions

Describe the bug
This bug basically makes std::variant unusable in the affected CUDA versions.

To Reproduce
I've seen this issue when trying to compile the latest dev branch of PIConGPU (2981b07a7160e64d057b5653f3d26410d54a8135) against the openPMD-api (version does not really matter, I used a4d66cc).

The error affects multiple usages of std::variant, e.g.:

/nix/store/6vclfnmcqpm1k5bbh5syf89f21gip2v3-gcc-12.3.0/include/c++/12.3.0/variant(391): error: function "std::__detail::__variant::_Variadic_union<_First, _Rest...>::~_Variadic_union() [with
 _First=unsigned int, _Rest=<unsigned long, unsigned long long, float, double, long double, std::complex<float>, std::complex<double>, std::complex<long double>, std::string, std::vector<cha
r, std::allocator<char>>, std::vector<short, std::allocator<short>>, std::vector<int, std::allocator<int>>, std::vector<long, std::allocator<long>>, std::vector<long long, std::allocator<lon
g long>>, std::vector<unsigned char, std::allocator<unsigned char>>, std::vector<unsigned short, std::allocator<unsigned short>>, std::vector<std::seed_seq::result_type, std::allocator<std::
seed_seq::result_type>>, std::vector<std::size_t, std::allocator<std::size_t>>, std::vector<unsigned long long, std::allocator<unsigned long long>>, std::vector<float, std::allocator<float>>
, std::vector<double, std::allocator<double>>, std::vector<long double, std::allocator<long double>>, std::vector<std::complex<float>, std::allocator<std::complex<float>>>, std::vector<std::
complex<double>, std::allocator<std::complex<double>>>, std::vector<std::complex<long double>, std::allocator<std::complex<long double>>>, std::vector<signed char, std::allocator<signed char
>>, std::vector<std::string, std::allocator<std::string>>, openpmd_array_double_7, bool>]" (declared at line 400) cannot be referenced -- it is a deleted function                            
   : _M_rest(in_place_index<_Np-1>, std::forward<_Args>(__args)...)                                                                                                                           
            ^                                                                                                                                                                                 
          detected during:
…
…
…
            instantiation of "std::__detail::__variant::_Move_ctor_base<<unnamed>, _Types...>::_Move_ctor_base(std::__detail::__variant::_Move_ctor_base<<unnamed>, _Types...> &&) [with <unna
med>=false, _Types=<char, unsigned char, signed char, short, int, long, long long, unsigned short, unsigned int, unsigned long, unsigned long long, float, double, long double, std::complex<f
loat>, std::complex<double>, std::complex<long double>, std::string, std::vector<char, std::allocator<char>>, std::vector<short, std::allocator<short>>, std::vector<int, std::allocator<int>>
, std::vector<long, std::allocator<long>>, std::vector<long long, std::allocator<long long>>, std::vector<unsigned char, std::allocator<unsigned char>>, std::vector<unsigned short, std::allo
cator<unsigned short>>, std::vector<std::seed_seq::result_type, std::allocator<std::seed_seq::result_type>>, std::vector<std::size_t, std::allocator<std::size_t>>, std::vector<unsigned long 
long, std::allocator<unsigned long long>>, std::vector<float, std::allocator<float>>, std::vector<double, std::allocator<double>>, std::vector<long double, std::allocator<long double>>, std:
:vector<std::complex<float>, std::allocator<std::complex<float>>>, std::vector<std::complex<double>, std::allocator<std::complex<double>>>, std::vector<std::complex<long double>, std::alloca
tor<std::complex<long double>>>, std::vector<signed char, std::allocator<signed char>>, std::vector<std::string, std::allocator<std::string>>, openpmd_array_double_7, bool>]" at line 59 of /
home/franzpoeschel/picongpu_env/env/include/openPMD/backend/Attribute.hpp

Line:

openPMD-api/include/openPMD/backend/Attribute.hpp

Line 55 in a4d66cc

class Attribute : public auxiliary::Variant<Datatype, attribute_types>

or

/nix/store/6vclfnmcqpm1k5bbh5syf89f21gip2v3-gcc-12.3.0/include/c++/12.3.0/variant(391): error: function "std::__detail::__variant::_Variadic_union<_First, _Rest...>::~_Variadic_union() [with
 _First=openPMD::UniquePtrWithLambda<void>, _Rest=<>]" (declared at line 400) cannot be referenced -- it is a deleted function                                                                
   : _M_rest(in_place_index<_Np-1>, std::forward<_Args>(__args)...)                                                                                                                           
            ^                                                                                                                                                                                 
          detected during:  
…
…
…
            instantiation of "std::variant<_Types...>::variant(_Tp &&) [with _Types=<std::shared_ptr<const void>, openPMD::UniquePtrWithLambda<void>>, _Tp=openPMD::UniquePtrWithLambda<void>,
 <unnamed>=void, <unnamed>=void, _Tj=openPMD::UniquePtrWithLambda<void>, <unnamed>=void]" at line 181 of /home/franzpoeschel/picongpu_env/env/include/openPMD/auxiliary/Memory.hpp

Line:

openPMD-api/include/openPMD/auxiliary/Memory.hpp

Line 178 in a4d66cc

EligibleTypes m_buffer;

What should we do

I don't see an easy way out of this. Looking at the linked bug report, even trivial use of std::variant seems to be impossible. In openPMD::Attribute, std::variant is part of our public API, so we can't easily replace it with something else.

  • Option 1: Check the affected CUDA versions, add some include guard to cancel compilation with the note that the CUDA version is broken and something else should be used.
  • Option 2: Reintroduce mpark::variant? It seems to be unmaintained though

Reproducer:

nix build gitlab:franzpoeschel/mynixpkgs/issue-1720#picongpu_LaserWakefield

Activity

  1. franzpoeschel
    added
    bug
    on Feb 20, 2025
  2. ax3l
    added
    affects latest release
    install
    third partythird party libraries that are shipped and/or linkedthird party libraries that are shipped and/or linked
    on Feb 20, 2025
  3. ax3l commented on Feb 20, 2025

    @ax3l
    ax3l
    on Feb 20, 2025
    Member
    More actions

    Thanks for documenting this C++20 issue with CUDA compilers! I encounter no problems with C++17 and std::variant in my projects.

    It looks to me like using CUDA 12.4.1+ fixes this for C++20:
    https://forums.developer.nvidia.com/t/nvcc-c-20-std-variant-complie-failed/270162/5

    So I think there are two solutions for people:

    • If you want to use C++20 with Nvidia compilers, use the latest compilers only for now. They already fixed this issue and we should keep reporting other bugs we find to https://developer.nvidia.com This is what we usually do when new standards are supported in vendor compilers and bugs are being shaken out still.
    • If you want to use std::variant and older Nvidia compilers, only require C++17 for now in downstream projects. (openPMD-api only needs C++17 currently)
  4. ax3l
    changed the title [-]CUDA bug affects use of openPMD-api in C++20 projects[/-] [+]CUDA < 12.4.1 bug affects use of openPMD-api in C++20 projects[/+] on Feb 20, 2025
  5. ax3l
    added
    wontfix
    workaround
    and removed
    affects latest release
    on Feb 20, 2025
  6. franzpoeschel
    added a commit that references this issue on Feb 27, 2025

    Add compile-time check for openPMD#1720

    7f3ea1f
  7. franzpoeschel
    added a commit that references this issue on Mar 14, 2025

    Add compile-time check for #1720 (#1722)

    0672293
  8. franzpoeschel commented on May 7, 2025

    @franzpoeschel
    franzpoeschel
    on May 7, 2025
    ContributorAuthor
    More actions

    This seems to particularly affect gcc 12.3.0, other versions (even within this minor release range) seem to work. Need to investigate again and maybe narrow down the error check.

  9. franzpoeschel
    added 3 commits that reference this issue on Jun 3, 2025

    Add compile-time check for openPMD#1720 (openPMD#1722)

    db3eb2f

    Add compile-time check for openPMD#1720 (openPMD#1722)

    26c026b

    Backport non-CI PRs (#1759): #1744 #1732 #1722 #1733 #1738 #1740 #1749

    5065b27
  10. franzpoeschel commented on Sep 1, 2025

    @franzpoeschel
    franzpoeschel
    on Sep 1, 2025
    ContributorAuthor
    More actions

    There is a chance that this was fixed by #1774, since that replaces public use of std::variant with std::any. Will need to check.

    Reacted by Axel Huebl
  11. ax3l
    assigned
    franzpoeschel
    on Nov 11, 2025
  12. franzpoeschel commented on Nov 14, 2025

    @franzpoeschel
    franzpoeschel
    on Nov 14, 2025
    ContributorAuthor
    More actions

    There is a chance that this was fixed by #1774, since that replaces public use of std::variant with std::any. Will need to check.

    Not entirely, but the fix is now in reach, ref. #1807

  13. franzpoeschel
    closed this as completedin #1807on Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @franzpoeschel
    franzpoeschel

Labels

buginstallthird partythird party libraries that are shipped and/or linkedthird party libraries that are shipped and/or linkedwontfixworkaround

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.