<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/100536>100536</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang][OpenMP] Implicit conversion with `pragma omp taskloop`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
rodarima
</td>
</tr>
</table>
<pre>
This small program fails to build with `-Werror -Wconversion`:
```c
int main(void)
{
#pragma omp parallel
#pragma omp single
{
#pragma omp taskloop
for (int i = 0; i < 10000; i++) {
#pragma omp task
{}
}
#pragma omp taskloop
for (long i = 0L; i < 10000L; i++) {
#pragma omp task
{}
}
#pragma omp taskloop
for (unsigned long i = 0UL; i < 10000UL; i++) {
#pragma omp task
{}
}
}
return 0;
}
```
```
+/usr/bin/zsh:12> clang -v
clang version 18.1.8
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/14.1.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
+/usr/bin/zsh:12> clang -fopenmp -Werror -Wconversion /tmp/tl.c -o /tmp/tl
/tmp/tl.c:7:8: error: implicit conversion changes signedness: 'long' to 'unsigned long' [-Werror,-Wsign-conversion]
7 | for (int i = 0; i < 10000; i++) {
| ~~~ ^~~
/tmp/tl.c:7:8: error: implicit conversion changes signedness: 'long' to 'unsigned long' [-Werror,-Wsign-conversion]
7 | for (int i = 0; i < 10000; i++) {
| ~~~ ^~~
/tmp/tl.c:13:8: error: implicit conversion changes signedness: 'unsigned long' to 'long' [-Werror,-Wsign-conversion]
13 | for (long i = 0L; i < 10000L; i++) {
| ^~~~
/tmp/tl.c:13:8: error: implicit conversion changes signedness: 'long' to 'unsigned long' [-Werror,-Wsign-conversion]
13 | for (long i = 0L; i < 10000L; i++) {
| ~~~ ^~~~
/tmp/tl.c:13:8: error: implicit conversion changes signedness: 'long' to 'unsigned long' [-Werror,-Wsign-conversion]
13 | for (long i = 0L; i < 10000L; i++) {
| ~~~ ^~~~
/tmp/tl.c:19:8: error: implicit conversion changes signedness: 'long' to 'unsigned long' [-Werror,-Wsign-conversion]
19 | for (unsigned long i = 0UL; i < 10000UL; i++) {
| ~~~ ^~~~~~~~
/tmp/tl.c:19:8: error: implicit conversion changes signedness: 'long' to 'unsigned long' [-Werror,-Wsign-conversion]
19 | for (unsigned long i = 0UL; i < 10000UL; i++) {
| ~~~ ^~~~~~~~
/tmp/tl.c:7:8: error: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Werror,-Wshorten-64-to-32]
7 | for (int i = 0; i < 10000; i++) {
| ^~~
8 errors generated.
```
It seems to be failing with any clang version back to 4.0.0
Godbolt: https://godbolt.org/z/drc7s4xjM
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsV9tu2zgTfhr6ZiCBInXyhS58qIoALf4f2Ba5XFASI7OlSIGkvOle-NkXlJzG1jrZHJpFC6xgJDwMZ775NCPOMGtFqzgvULJGyXbBBrfTpjC6YUZ0bFHp5lvxaScs2I5JCb3RrWEd3DAhLTgN1SBkA38ItwOU4uCaG6MNBNe1VnturNAKpRjRFcJbhFd-PP7qaS6Ug44JhUi-16JBZHmUy9bHAV4iQnvD2o6B7nromWFScvnAthWqlfx-81TPXNYx-1Vq3Z9K3GgDiOQelwBEt4ARXY_DDUQY42mKyHr8LWFu4JKNuUC2Rtn2bPF--gKsUqv2DuyHGdoPPx_cQY0R18Ap7s9z4J_fGvnZ2HA3GDW-67v4284C9szj2aJHWA7WIFJWPpbLP-0O0VVEEH0HtWSqhWA_yU6zY2ZAlIdRmE87n5hpuUN0Bbd5-nsaB30dSKGG26BVw1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