<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 - Math function conflict when using clang++"
   href="https://bugs.llvm.org/show_bug.cgi?id=42061">42061</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Math function conflict when using clang++
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>OpenMP
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Clang Compiler Support
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>csdaley@lbl.gov
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I encounter a math function conflict issue when using clang++. The conflict
does not happen when using clang. I am using LLVM/Clang/OpenMP commits from
today, 29 May 2019. Please see below

csdaley@cgpu03:~/llvm> cat hello.c
#include <stdio.h>
#include <stdlib.h>

int main()
{
  printf("hello\n");
  return 0;
}

csdaley@cgpu03:~/llvm> clang -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda
hello.c -o hello && ./hello 
hello

csdaley@cgpu03:~/llvm> clang++ -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda
hello.c -o hello && ./hello 
clang-9: warning: treating 'c' input as 'c++' when in C++ mode, this behavior
is deprecated [-Wdeprecated]
In file included from hello.c:2:
In file included from /opt/gcc/7.3.0/snos/include/g++/stdlib.h:36:
In file included from /opt/gcc/7.3.0/snos/include/g++/cstdlib:77:
/opt/gcc/7.3.0/snos/include/g++/bits/std_abs.h:70:3: error: declaration
conflicts with target of using declaration already in scope
  abs(double __x)
  ^
/project/projectdirs/m1759/csdaley/software/cgpu/llvm/9.0.0-git_20190529/lib/clang/9.0.0/include/__clang_cuda_math_forward_declares.h:50:25:
note: target of using declaration
__DEVICE__ const double abs(const double);
                        ^
/opt/gcc/7.3.0/snos/include/g++/bits/std_abs.h:52:11: note: using declaration
  using ::abs;
          ^
/opt/gcc/7.3.0/snos/include/g++/bits/std_abs.h:74:3: error: declaration
conflicts with target of using declaration already in scope
  abs(float __x)
  ^
/project/projectdirs/m1759/csdaley/software/cgpu/llvm/9.0.0-git_20190529/lib/clang/9.0.0/include/__clang_cuda_math_forward_declares.h:51:24:
note: target of using declaration
__DEVICE__ const float abs(const float);
                       ^
/opt/gcc/7.3.0/snos/include/g++/bits/std_abs.h:52:11: note: using declaration
  using ::abs;
          ^
2 errors generated.

csdaley@cgpu03:~/llvm> clang++ -v
clang version 9.0.0 (<a href="https://github.com/llvm-mirror/clang">https://github.com/llvm-mirror/clang</a>
e420b2015caea78d84601f697fbc33b6116ec622) (<a href="https://github.com/llvm-mirror/llvm">https://github.com/llvm-mirror/llvm</a>
36c062c0837bba4d6fc18b4132ab3df6a8cc4113)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
/project/projectdirs/m1759/csdaley/software/cgpu/llvm/9.0.0-git_20190529/bin
Found candidate GCC installation:
/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0
Selected GCC installation: /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /global/common/cori/software/cuda/9.2, version 9.2



I have been in discussion with Doru and Johannes about this bug. They confirmed
that it is a bug and suggested putting the bug in bugzilla. The latest response
from Doru is

"The fix would be to remove the const float and const double variants of the
abs functions. This unfortunately will break the inclusion of the "random"
header.

I'm not sure how to reconcile those two errors, it looks like those two fixes
cannot coexist. Maybe I'm missing something."

Thanks,
Chris</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>