Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error with clang in CUDA mode #3740

Closed
msimberg opened this issue Dec 8, 2023 · 1 comment · Fixed by #3751
Closed

Compilation error with clang in CUDA mode #3740

msimberg opened this issue Dec 8, 2023 · 1 comment · Fixed by #3751

Comments

@msimberg
Copy link
Contributor

msimberg commented Dec 8, 2023

When compiling

fmt/include/fmt/std.h

Lines 418 to 419 in 6f95000

std::unique_ptr<char, decltype(&std::free)> demangled_name_ptr(
abi::__cxa_demangle(ti.name(), nullptr, &size, &status), &std::free);
with clang in CUDA mode, compilation fails because std::free is an overloaded function. This small reproducer shows the problem on compiler explorer: https://godbolt.org/z/1bdKf86f9 (unfortunately for an older version of clang and cuda and without fmt, but the issue is the same). Device overloads are considered separate overloads with clang in CUDA mode, which means that taking the address of std::free doesn't work.

Note, we're not trying to use fmt in device code and don't expect this to work in device code, this is purely host code that just happens to be included in a .cu file.

This code seems to have been added in #3076, and so the problem appears from version 10.0.0 onwards.

Would you accept a patch to

  • e.g. choose the #else branch of that implementation when in CUDA mode with clang?
  • replace decltype(&std::free) with void(void*)?
  • some other workaround?
@vitaut
Copy link
Contributor

vitaut commented Dec 8, 2023

I think replacing decltype(&std::free) with void(void*) is reasonable. A PR is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants