<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 - Compilation errors when including iostream in OpenMP NVPTX offloading code"
href="https://bugs.llvm.org/show_bug.cgi?id=41861">41861</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Compilation errors when including iostream in OpenMP NVPTX offloading code
</td>
</tr>
<tr>
<th>Product</th>
<td>OpenMP
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</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>Clang Compiler Support
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>p.atkinson@bristol.ac.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>The following code will fail to compile with Clang configured to use OpenMP
NVPTX offloading.
#include <cstdio>
#include <iostream>
int main()
{
#pragma omp target
{
printf("foo\n");
}
}
Compiler output:
~ $ clang++ test.cpp -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda
-Xopenmp-target -march=sm_60
In file included from test.cpp:2:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/iostream:39:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ostream:38:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ios:42:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/ios_base.h:39:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ext/atomicity.h:35:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux/bits/gthr.h:148:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux/bits/gthr-default.h:35:
In file included from /usr/include/pthread.h:24:
/usr/include/time.h:189:16: error: functions that differ only in their return
type cannot be overloaded
extern clock_t clock (void) __THROW;
~~~~~~~ ^
/lustre/home/br-patkinson/modules/x86_64/llvm/install/lib/clang/9.0.0/include/__clang_cuda_device_functions.h:1496:16:
note: previous definition is here
__DEVICE__ int clock() { return __nvvm_read_ptx_sreg_clock(); }
~~~ ^
In file included from test.cpp:2:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/iostream:39:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ostream:38:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ios:42:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/ios_base.h:41:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/locale_classes.h:40:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/string:52:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/basic_string.h:2815:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ext/string_conversions.h:41:
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:166:3:
error: declaration conflicts with target of using declaration already in scope
abs(long __i) { return __builtin_labs(__i); }
^
/lustre/home/br-patkinson/modules/x86_64/llvm/install/lib/clang/9.0.0/include/__clang_cuda_cmath.h:40:17:
note: target of using declaration
__DEVICE__ long abs(long __n) { return ::labs(__n); }
^
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
note: using declaration
using ::abs;
^
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:174:3:
error: declaration conflicts with target of using declaration already in scope
abs(long long __x) { return __builtin_llabs (__x); }
^
/lustre/home/br-patkinson/modules/x86_64/llvm/install/lib/clang/9.0.0/include/__clang_cuda_cmath.h:39:22:
note: target of using declaration
__DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
^
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
note: using declaration
using ::abs;
^
3 errors generated.
It seems there's a declaration conflict between the C standard library headers
and the '__clang_cuda' headers.
When '#include <iostream>' is removed from the above example, the code compiles
and works fine.</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>