[PATCH] D77954: [CUDA][HIP] Fix host/device based overload resolution

Dmitri Gribenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 27 08:01:44 PDT 2020


gribozavr2 added a comment.

Sorry -- this change broke overload resolution for `operator new`, as it is declared in system headers. I'm reverting the patch.

  $ cat /tmp/in.cu.cc
  #define __device__ __attribute__((device))
  void* operator new(__SIZE_TYPE__ size);
  __device__ void *operator new(__SIZE_TYPE__ size);
  void *x = new int;
  $ clang -fsyntax-only --cuda-device-only --target=x86_64-grtev4-linux-gnu -x cuda -nocudalib -nocudainc -std=gnu++17 /tmp/in.cu.cc
  /tmp/in.cu.cc:4:11: error: call to 'operator new' is ambiguous
  void *x = new int;
            ^
  /tmp/in.cu.cc:2:7: note: candidate function
  void* operator new(__SIZE_TYPE__ size);
        ^
  /tmp/in.cu.cc:3:18: note: candidate function
  __device__ void *operator new(__SIZE_TYPE__ size);
                   ^
  1 error generated when compiling for sm_20.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77954





More information about the cfe-commits mailing list