[llvm-bugs] [Bug 37753] New: std::min and std::max cannot be used in __host__ __device__ functions under C++14

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 8 13:02:39 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37753

            Bug ID: 37753
           Summary: std::min and std::max cannot be used in __host__
                    __device__ functions under C++14
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: CUDA
          Assignee: unassignedclangbugs at nondot.org
          Reporter: j.l.k at gmx.com
                CC: llvm-bugs at lists.llvm.org

The following commit does not do the right thing because it makes it impossible
to use the std::min and std::max functions in __host__ __device__ functions
under C++14.

https://github.com/llvm-mirror/clang/commit/                                 
2528a79005f7195f1ede353e21688e5223ac2460#diff-0df73228daf7d086a1a4baf1dc1b092e

Simple repro case:

////////////////////

#include <algorithm>
#include <cstdio>

__host__ __device__
void print_min(int a, int b)
{
    printf("min(%d, %d) = %d\n", a, b, std::min(a, b));
}

int main()
{
    print_min(1, 2);
    return 0;
}

////////////////////

Compilation with nvcc from CUDA 9.2 succeeds: `nvcc -std=c++14
--expt-relaxed-constexpr std_min.cu -o std_min`

clang 7.0.0 (trunk 334304) fails: `clang++ -std=c++14 --cuda-gpu-arch=sm_61
std_min.cu -o std_min`

Actual error message:

std_min.cu:13:45: error: reference to __device__ function 'min<int>' in
__host__             __device__
      function
    printf("min(%d, %d) = %d\n", a, b, std::min(a, b));
                                            ^
/usr/lib/clang/7.0.0/include/cuda_wrappers/algorithm:94:1: note: 'min<int>'
declared here//      min(const __T &__a, const __T &__b) {
^
1 error generated when compiling for host.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180608/5cd90d7e/attachment.html>


More information about the llvm-bugs mailing list