[PATCH] D71227: [cuda][hip] Fix function overload resolution in the global initiailizer.

Michael Liao via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 10 19:31:22 PST 2019


hliao added a comment.

In D71227#1778136 <https://reviews.llvm.org/D71227#1778136>, @tra wrote:

> I wonder if this patch will help with this case:
>
> https://godbolt.org/z/X4KdsV
>
>   __device__ float fn(int) { return threadIdx.x; };
>   __host__ float fn(float);
>  
>   float gvar1 = []()__device__ { return fn(1);} (); // This ends up calling fn(int) on *host*
>  
>
>
> We seem to happily let host code call __device__ function from a lambda function used as an initializer.


It's turned out that `Sema::CheckCUDACall` needs to consider global initializer as well. I will revise that part.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71227/new/

https://reviews.llvm.org/D71227





More information about the cfe-commits mailing list