Skip to content

Bug reports submitted to NVIDIA

js75 edited this page Jul 23, 2015 · 6 revisions

Compilation fails when using unnamed type template parameters in host code

Metainformation

NVIDIA bug #1667662

Submission date: Jul 22, 2015

Status: Closed - fixed

The bugfix will be delivered with CUDA 7.5

Summary

Compilation fails when using unnamed type template parameters in host code

Description

Consider the minimal example in Duplication Steps. When compiling with nvcc, gcc 4.9 and the C++11 standard compilation will fail. Unfortunately I can not include the error log here as the bug tracker's spam filter will not allow me to submit the bug but it goes along the lines of '__T0 was not declared in this scope'.

When looking at the preprocessed files nvcc transformed the second struct constructor to instantiate the default constructor with the parameters T and __T0. __T0 is of course undefined and thus causes an error once gcc takes over.

This can be worked around by giving the unnamed type parameter a name.

Duplication Steps

template<class T, int>
class A
{
    A() = default;
    A(int) : A()
    {
    }
};

int main()
{
    return 0;
}

CUDA Toolkit Details

I am using CUDA Toolkit 7.0 as delivered by my distribution (Arch Linux):

cuda 7.0.28-2

Operating System Details

I am using Arch Linux on the x86_64 platform.

Compilation fails on alias templates

Metainformation

NVIDIA bug #1667660

Submission date: Jul 22, 2015

Status: Open - in progress

NVIDIA were able to reproduce the bug locally and to identify the root cause. The fix is currently being developed, they are aiming to deliver it with CUDA 7.5.

Summary

Compilation fails on alias templates

Description

Consider the minimal example in Duplication Steps. When compiling with nvcc and gcc4.9 and the C++11 standard compilation will fail. Unfortunately I can not include the error log here as the bug tracker's spam filter will not allow me to submit the bug but it goes along the lines of 'template argument 1 is invalid'. When looking at the preprocessed files (passing the keep option) it seems that cudafe++ simply strips the template arguments from the alias and thus compilation fails.

This can be worked around by placing the using decltype directive in a struct and then modify the using tester directive to point to the struct member.

Duplication Steps

#include <type_traits>
#include <utility>

template<typename F, typename A>
std::true_type test(int bla);

template<typename F, typename A>
std::false_type test(...);

template<typename F, typename A>
using tester = decltype(test<F, A>(1));

template<typename X, typename Y>
typename
std::enable_if<tester<X, Y>::value, Y>::type foo()
{
    return 0;
}

int main()
{
    return 0;
}

CUDA Toolkit Details

I am using CUDA Toolkit 7.0 as delivered by my distribution (Arch Linux):

cuda 7.0.28-2

Operating System Details

I am using Arch Linux on the x86_64 platform.

Compilation fails when using non-type template parameters

Metainformation

NVIDIA bug #1668080

Submission date: Jul 23, 2015

Status: Open - in progress

NVIDIA were able to reproduce the error and assigned the task to the appropriate developer team.

Summary

Consider the minimal example in Duplication Steps. When compiling with nvcc, gcc 4.9 and the C++11 standard compilation will fail. Error log:

non-type_template_parameter.cu(4): : constant "value" is not a type name

This is true for both CUDA 7.0 and CUDA 7.5 RC

Duplication Steps

template<typename... Ts> struct A
{
    template<typename U, template<typename, typename, U> class C, U value>
    using B = C<Ts..., value>;
};

int main()
{
    return 0;
}

CUDA Toolkit Details

I tested this with CUDA 7.0 as delivered by my distribution and the generic CUDA 7.5 RC.

Operating System Details

I am using Arch Linux on the x86_64 platform.