Skip to content

[CUDA][HIP] shared variable not allowed with trivial ctor #116922

Open
@aywala

Description

@aywala

Similar with #72261

struct A {
  A(){}
  ~A() {}
  int x;
};

#define __device__ __attribute__((device))
#define __shared__ __attribute__((shared))

__device__ A x;

__device__ void foo() {
  __shared__ A y;  // error with clang, ok with nvcc
}

#73140 fixed global device var init, but non-global shared var still fails.

nvcc does not check host device attribute for either global device var or shared var.

nvcc even does not report error when constructor for shared var is not empty ( just report warning, but the constructor will never be called).

@yxsamliu

https://godbolt.org/z/5T9fKdavn
https://godbolt.org/z/GqW6PTG18

Metadata

Metadata

Assignees

Labels

cudaquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions