# A bug of NVCC compiler

**URL:** <https://forums.developer.nvidia.com/t/a-bug-of-nvcc-compiler/205773>\
**Category:** CUDA NVCC Compiler\
**Created:** [March 12, 2022, 4:16am UTC](https://forums.developer.nvidia.com/t/a-bug-of-nvcc-compiler/205773 "2022-03-12T04:16:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![982630737](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@982630737](https://forums.developer.nvidia.com/u/982630737)\
**Post date:** [March 12, 2022, 4:16am UTC](https://forums.developer.nvidia.com/t/a-bug-of-nvcc-compiler/205773/1 "2022-03-12T04:16:05Z")

</div>

I write a simple C++14 program which can be correctly compiled by gcc, but cannot be compiled by nvcc. The minimal reproducible code is shown below:

```auto
#include<cstdio>

template <int K>
struct Struct {
    int a;
};

template <int K, int... Ks, typename F>
void apply(F func, int KK) {
    if (KK == K) {
        Struct<K> i{K};
        func(i);
        return;
    }
    apply<Ks...>(func, KK);
}

template <typename F>
void apply(F func, int KK) {}

int main() {
    auto fun = [](auto i) { printf("enter %d\n", i.a); };
    apply<1, 2, 3>(fun, 1);
}

```

The compilation error is shown below:

```auto
error: no instance of overloaded function "apply" matches the argument list
            argument types are: (lambda [](auto)->auto, int)
          detected during:
            instantiation of "void apply<K,Ks...,F>(F, int) [with K=3, Ks=<>, F=lambda [](auto)->auto]"
(15): here
            instantiation of "void apply<K,Ks...,F>(F, int) [with K=2, Ks=<3>, F=lambda [](auto)->auto]"
(15): here
            instantiation of "void apply<K,Ks...,F>(F, int) [with K=1, Ks=<2, 3>, F=lambda [](auto)->auto]"
(23): here

```
