Skip to content

Fix CUDA 13.1 compile failure: use trailing return types for dependent name resolution#75

Draft
Copilot wants to merge 2 commits intomini20from
copilot/fix-compile-failure-cuda
Draft

Fix CUDA 13.1 compile failure: use trailing return types for dependent name resolution#75
Copilot wants to merge 2 commits intomini20from
copilot/fix-compile-failure-cuda

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 7, 2026

CUDA 13.1's cudafe++ fails to match the leading return type ComputeGraphVar<XxxView<T>>& (written before the scope qualifier) against the declaration's ComputeGraphVar<VarType>& where VarType is a dependent type alias. This affects all four ComputeGraphVar partial specialization .inl files.

  • Use trailing return types so VarType resolves within class scope:
// Before
template <typename T>
MUDA_INLINE ComputeGraphVar<VarView<T>>& ComputeGraphVar<VarView<T>>::operator=(const RWView& view)

// After
template <typename T>
MUDA_INLINE auto ComputeGraphVar<VarView<T>>::operator=(const RWView& view) -> ComputeGraphVar<VarType>&
  • Applied to graph_var_view.inl, graph_buffer_view.inl, graph_buffer_2d_view.inl, graph_buffer_3d_view.inl
Original prompt

This section details on the original issue you should resolve

<issue_title>Compile failure about the dependent names resolve using CUDA 13.1</issue_title>
<issue_description>## What happened

Environment:

  • GCC 15.2.1
  • CUDA release 13.1, V13.1.115
  • CMAKE 4.2.3

Compiling muda with the tools above:

mkdir build
cd build
cmkae -S .. -B .
make

nvcc reports:

/home/ll06/src/muda/src/muda/buffer/details/graph_var_view.inl(10): error: declaration is incompatible with "muda::ComputeGraphVar<muda::ComputeGraphVar<muda::VarView<T>>::VarType> &muda::ComputeGraphVar<muda::VarView<T>>::operator=(const muda::ComputeGraphVar<muda::VarView<T>>::RWView &)" (declared at line 48 of /home/ll06/src/muda/src/muda/buffer/graph_var_view.h)
  inline ComputeGraphVar<VarView<T>>& ComputeGraphVar<VarView<T>>::operator=(const RWView& view)
                                                                   ^

/home/ll06/src/muda/src/muda/buffer/details/graph_buffer_view.inl(10): error: declaration is incompatible with "muda::ComputeGraphVar<muda::ComputeGraphVar<muda::BufferView<T>>::VarType> &muda::ComputeGraphVar<muda::BufferView<T>>::operator=(const muda::ComputeGraphVar<muda::BufferView<T>>::RWView &)" (declared at line 51 of /home/ll06/src/muda/src/muda/buffer/graph_buffer_view.h)
  inline ComputeGraphVar<BufferView<T>>& ComputeGraphVar<BufferView<T>>::operator=(const RWView& view)
                                                                         ^

/home/ll06/src/muda/src/muda/buffer/details/graph_buffer_2d_view.inl(10): error: declaration is incompatible with "muda::ComputeGraphVar<muda::ComputeGraphVar<muda::Buffer2DView<T>>::VarType> &muda::ComputeGraphVar<muda::Buffer2DView<T>>::operator=(const muda::ComputeGraphVar<muda::Buffer2DView<T>>::RWView &)" (declared at line 51 of /home/ll06/src/muda/src/muda/buffer/graph_buffer_2d_view.h)
  inline ComputeGraphVar<Buffer2DView<T>>& ComputeGraphVar<Buffer2DView<T>>::operator=(const RWView& view)
                                                                             ^

/home/ll06/src/muda/src/muda/buffer/details/graph_buffer_3d_view.inl(10): error: declaration is incompatible with "muda::ComputeGraphVar<muda::ComputeGraphVar<muda::Buffer3DView<T>>::VarType> &muda::ComputeGraphVar<muda::Buffer3DView<T>>::operator=(const muda::ComputeGraphVar<muda::Buffer3DView<T>>::RWView &)" (declared at line 51 of /home/ll06/src/muda/src/muda/buffer/graph_buffer_3d_view.h)
  inline ComputeGraphVar<Buffer3DView<T>>& ComputeGraphVar<Buffer3DView<T>>::operator=(const RWView& view)

According to the test, the following files have the same problem:

  • graph_buffer_2d_view.inl
  • graph_buffer_3d_view.inl
  • graph_buffer_view.inl
  • graph_var_view.inl

Possible reason

Here is a snippet that could make nvcc report the same error:

// Common pattern of these file.
namespace muda {

template <bool IsConst, typename T> struct VarView {};


template <typename T>
using var_view = VarView<false, T>;

template <typename T>
class ComputeGraphVar {
public:
    using VarType = T;
    using RWView = T;

    ComputeGraphVar<VarType>& operator=(const RWView& view) {}
};

template <typename T>
class ComputeGraphVar<var_view<T>> {

using VarType = var_view<T>;
using RWView = var_view<T>;

    ComputeGraphVar<VarType>& operator=(const RWView& view);
};

template <typename U>
inline ComputeGraphVar<var_view<U>>&
ComputeGraphVar<var_view<U>>::operator=(const var_view<U>& view) {
    return *this;
}

}

int main() {
    muda::ComputeGraphVar<muda::var_view<int>> v;
    return 0;
}

Compile the snippet with command

$ nvcc -o exp exp.cu --verbose
#$ "/usr/bin"/g++ -D__CUDA_ARCH_LIST__=750 -E -x c++ -D__CUDACC__ -D__NVCC__  "-I/opt/cuda/bin/../targets/x86_64-linux/include"   "-isystem" "/opt/cuda/bin/../targets/x86_64-linux/include/cccl"    -D__CUDACC_VER_MAJOR__=13 -D__CUDACC_VER_MINOR__=1 -D__CUDACC_VER_BUILD__=115 -D__CUDA_API_VER_MAJOR__=13 -D__CUDA_API_VER_MINOR__=1 -D__NVCC_DIAG_PRAGMA_SUPPORT__=1 -D__CUDACC_DEVICE_ATOMIC_BUILTINS__=1 -include "cuda_runtime.h" -m64 "exp.cu" -o "/tmp/tmpxft_00002618_00000000-5_exp.cpp4.ii" 
#$ cudafe++ --c++17 --static-host-stub --device-hidden-visibility --gnu_version=150201 --display_error_number --orig_src_file_name "exp.cu" --orig_src_path_name "/home/ll06/src/muda/build/tmp/exp.cu" --allow_managed  --m64 --parse_templates --gen_c_file_name "/tmp/tmpxft_00002618_00000000-6_exp.cudafe1.cpp" --stub_file_name "tmpxft_00002618_00000000-6_exp.cudafe1.stub.c" --gen_module_id_file --module_id_file_name "/tmp/tmpxft_00002618_00000000-4_exp.module_id" "/tmp/tmpxft_00002618_00000000-5_exp.cpp4.ii" 
exp.cu(30): error: declaration is incompatible with "muda::ComputeGraphVar<muda::ComputeGraphVar<muda::var_view<T>>::VarType> &muda::ComputeGraphVar<muda::var_view<T>>::operator=(const muda::ComputeGraphVar<muda::var_view<T>>::RWView &)" (declared at line 25)
  ComputeGraphVar<var_view<U>>::operator=(const var_view<U>& view)...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes MuGdxy/muda#74

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for you](https://github.com/MuGdxy/muda/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.

…t name resolution

In the 4 affected .inl files, the out-of-class operator= definitions used a
leading return type that appears before the class scope qualifier. CUDA 13.1's
cudafe++ has stricter dependent name resolution and doesn't match
ComputeGraphVar<XxxView<T>>& against the declaration's
ComputeGraphVar<VarType>& where VarType is a dependent type alias.

The fix uses trailing return types (auto ... -> ComputeGraphVar<VarType>&) so
that VarType is resolved within the class scope, matching the header
declarations.

Co-authored-by: MuGdxy <52098265+MuGdxy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix compile failure about dependent names resolve using CUDA 13.1 Fix CUDA 13.1 compile failure: use trailing return types for dependent name resolution Mar 7, 2026
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 this pull request may close these issues.

2 participants