Skip to content

[CUDA][HIP] file-scope device variable not allowed with trivial ctor #72261

@yxsamliu

Description

@yxsamliu

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

device A x;`

the above code is allowed with nvcc but not cuda-clang.

https://godbolt.org/z/jjMG3zTd3

https://godbolt.org/z/74Ed1WvGn

nvcc allows it not because it makes the ctor A::A() implicitly host device (this can be seen by defining A x in device function), but because it does not check host/device availability for file-scope device var.

I think it makes sense to make trivial ctor/dtor implicitly host device.

@Artem-B

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"cuda

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions