[PATCH] D79526: [CUDA][HIP] Workaround for resolving host device function against wrong-sided function

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 18 15:12:20 PDT 2020


tra added a comment.

Reduced test case:

  struct a {
    __attribute__((device)) a(short);
    __attribute__((device)) operator unsigned() const;
    __attribute__((device)) operator int() const;
  };
  struct b {
    a d;
  };
  void f(b g) { b e = g; }

Failure:

  $ bin/clang++ -x cuda aten.cc -fsyntax-only  --cuda-path=$HOME/local/cuda-10.1 --cuda-device-only --cuda-gpu-arch=sm_60 -stdlib=libc++ -std=c++17 -ferror-limit=1
  
  aten.cc:6:8: error: conversion from 'const a' to 'short' is ambiguous
  struct b {
         ^
  aten.cc:9:21: note: in implicit copy constructor for 'b' first required here
  void f(b g) { b e = g; }
                      ^
  aten.cc:3:27: note: candidate function
    __attribute__((device)) operator unsigned() const;
                            ^
  aten.cc:4:27: note: candidate function
    __attribute__((device)) operator int() const;
                            ^
  aten.cc:2:34: note: passing argument to parameter here
    __attribute__((device)) a(short);
                                   ^
  1 error generated when compiling for sm_60.

The same code compiles fine in C++ and I would expect it to work on device side the same way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79526





More information about the cfe-commits mailing list