Issue 120516
Summary [CUDA] should report error for inline __device__ variable
Labels new issue
Assignees
Reporter aywala
    see [CUDA - inline variable](https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#inline-variable)
A namespace scope inline variable declared with __device__ or __constant__ or __managed__ memory space specifier must have internal linkage, if the code is compiled with nvcc in whole program compilation mode.

```cpp
#include <stdio.h>

__device__ inline int a = 10;

__global__ void kernel() {
 printf("%d\n",a);
}

int main() {
    kernel<<<1,1>>>();
 cudaDeviceSynchronize();
}
```
```
nvcc report_error.cu -o report_error
report_error.cu(3): error: An inline __device__/__constant__/__managed__ variable must have internal linkage when the program is compiled in whole program mode (-rdc=false)
 __attribute__((device)) inline int a = 10;
 ^

1 error detected in the compilation of "report_error.cu".
```
but no error report with
``clang++ report_error.cu -o report_error --cuda-gpu-arch=sm_52 -L /usr/local/cuda/lib64 -lcudart -pthread``
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to