<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 - Declaration conflict between __clang_cuda_math_forward_declares.h and libstdc++"
   href="https://bugs.llvm.org/show_bug.cgi?id=42972">42972</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Declaration conflict between __clang_cuda_math_forward_declares.h and libstdc++
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>jonathanchesterfield@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Tagged as cuda, but the problem may only reproduce from openmp.

The abs definition introduced in <a href="https://reviews.llvm.org/D62046">https://reviews.llvm.org/D62046</a> breaks
<iostream> and <algorithm> when mixed with libstdc++ 7.4 and openmp, e.g.

test.cpp:
`#include <iostream>`

~/llvm-install/bin/clang++ -std=c++11 -fopenmp
-fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda
-march=sm_50 -nocudalib -o test.x test.cpp

abs returning a const value seems a bit weird, I don't follow the reasoning in
the diff that makes this necessary.

```
In file included from
/usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/algorithm:62:
In file included from
/usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/stl_algo.h:59:
In file included from
/usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/cstdlib:77:
/usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/std_abs.h:70:3:
error: 
      declaration conflicts with target of using declaration already in scope
  abs(double __x)
  ^
/home/jon/llvm-install/lib/clang/10.0.0/include/__clang_cuda_math_forward_declares.h:50:25:
note: 
      target of using declaration
__DEVICE__ const double abs(const double);
                        ^
/usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/std_abs.h:52:11:
note: using
      declaration
  using ::abs;
          ^
/usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/std_abs.h:74:3:
error: 
      declaration conflicts with target of using declaration already in scope
  abs(float __x)
  ^
/home/jon/llvm-install/lib/clang/10.0.0/include/__clang_cuda_math_forward_declares.h:51:24:
note: 
      target of using declaration
__DEVICE__ const float abs(const float);
                       ^
/usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/std_abs.h:52:11:
note: using
      declaration
  using ::abs;
          ^
2 errors generated.
```</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>