<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - clang -x cuda requires duplicating __host__ and __device__ specifiers"
   href="https://bugs.llvm.org/show_bug.cgi?id=34508">34508</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang -x cuda requires duplicating __host__ and __device__ specifiers
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>CUDA
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ibiryukov@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following code compiles with nvcc and fails to compile with clang.

    struct X {
        __device__ __host__ int foo();
    };


    int X::foo() {
        return 10;
    }

    namespace ns {
        __device__ __host__ int bar();
    }

    int ns::bar() {
        return 20;
    }

clang assumes __host__ specifier on out-of-line definitions, producing
following errors:

    cuda2.cu:6:12: error: __host__ function 'foo' cannot overload __host__
__device__ function 'foo'
        int X::foo() {
               ^
    cuda2.cu:2:33: note: previous declaration is here
            __device__ __host__ int foo();
                                    ^
    cuda2.cu:14:13: error: __host__ function 'bar' cannot overload __host__
__device__ function 'bar'
        int ns::bar() {
                ^
    cuda2.cu:11:33: note: previous declaration is here
            __device__ __host__ int bar();
                                    ^


It seems that nvcc is doing the right thing here, not requiring to duplicate
specifiers.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>