[llvm-bugs] [Bug 34508] New: clang -x cuda requires duplicating __host__ and __device__ specifiers

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 6 09:28:14 PDT 2017


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

            Bug ID: 34508
           Summary: clang -x cuda requires duplicating __host__ and
                    __device__ specifiers
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: CUDA
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ibiryukov at google.com
                CC: llvm-bugs at lists.llvm.org

The following code compiles with nvcc and fails to compile with clang.

    struct X {
        __device__ __host__ int foo();
    };


    int X::foo() {
        return 10;
    }

    namespace ns {
        __device__ __host__ int bar();
    }

    int ns::bar() {
        return 20;
    }

clang assumes __host__ specifier on out-of-line definitions, producing
following errors:

    cuda2.cu:6:12: error: __host__ function 'foo' cannot overload __host__
__device__ function 'foo'
        int X::foo() {
               ^
    cuda2.cu:2:33: note: previous declaration is here
            __device__ __host__ int foo();
                                    ^
    cuda2.cu:14:13: error: __host__ function 'bar' cannot overload __host__
__device__ function 'bar'
        int ns::bar() {
                ^
    cuda2.cu:11:33: note: previous declaration is here
            __device__ __host__ int bar();
                                    ^


It seems that nvcc is doing the right thing here, not requiring to duplicate
specifiers.

-- 
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/20170906/2663d025/attachment.html>


More information about the llvm-bugs mailing list