<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68942>68942</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Extraneous warning messages with printf format warning in Openmp offload regions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
markdewing
</td>
</tr>
</table>
<pre>
If the printf format specifier does not match the variable type, clang can issue a warning message.
If the printf function is inside an OpenMP offload region, a number of extra warning messages can be issued.
It seems to only occur if all the variables in the local scope are used in the offload region.
Example:
```
int main()
{
double a = 100;
#pragma omp target
{
printf("target a = %d\n",a);
}
}
```
Compiled with: `clang++ -fopenmp -fopenmp-targets=nvptx64 printf_extra_warnings.cpp` will produce the expected
```
printf_extra_warnings.cpp:9:34: warning: format specifies type 'int' but the argument has type 'double' [-Wformat]
9 | printf("target a = %d\n",a);
| ~~ ^
| %f
1 warning generated.
printf_extra_warnings.cpp:9:34: warning: format specifies type 'int' but the argument has type 'double' [-Wformat]
9 | printf("target a = %d\n",a);
| ~~ ^
| %f
```
And then additional warnings get output:
```
/mnt/prev/home/mdewing/software/llvm/github/usr_main/lib/clang/18/include/__clang_cuda_device_functions.h:38:36: note: used here
38 | __DEVICE__ void __brkpt(int __a) { __brkpt(); }
| ^
/mnt/prev/home/mdewing/software/llvm/github/usr_main/lib/clang/18/include/__clang_cuda_device_functions.h:1189:22: note: used here
1189 | return __bool2mask(__vseteq2(__a, __b), 16);
| ^
/mnt/prev/home/mdewing/software/llvm/github/usr_main/lib/clang/18/include/__clang_cuda_device_functions.h:1189:10: note: used here
1189 | return __bool2mask(__vseteq2(__a, __b), 16);
| ^
...
```
If a variable is added to the local scope and is not used in the offload region, the extra warnings do not happen
```
int main()
{
double a = 100;
int b;
#pragma omp target
{
printf("target a = %d\n",a);
}
}
```
Use the variable in the offload region, the extra warnings reappear:
```
int main()
{
double a = 100;
int b;
#pragma omp target
{
printf("target a = %d\n",a);
b = 1;
}
}
```
clang version 18.0.0 (https://github.com/llvm/llvm-project.git 6f5b372d593f1d08f6569a32f529b6bd5106237c)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMV8uOozgXfhpnc1QI7EDIIotKUpF68eufzcwskcEH4mlje2yTVG_q2UeGXCrprlJfNKOyImJ8O5-_c4V7LzuNuCL5muTbGR_C3rhVz91ngUepu1ltxJfVpxbCHsE6qUMLrXE9D-AtNrKV6EAY9KBNgJ6HZj8uPXAnea0QwheLhG6gUVx30HAN0vsBgcOROy11Bz16zztMSLol6eOdqEE3QZq4CaT2UiBwDf-3qP_3G5i2VYYLcNhJo6MQDnroa3RgWsDn4L4S4kcENU4gxFlmAI_YewgGjFZfwDTN4EC2wJW6uU5EMQ4o03AFvjEWgTuEwaM4z93iOsmYnk_PvLcKCTu9kyI9_cZXqSOHUhNaErqcxgDIYn3uxibMEInlQNgWsjQl7DJNKLOOdz0H01sI3HUYXm-9njTxO8qh07rTgYTmguQbTSgldMMjDLa-PWN7Bbb95jU2prdSoYCjDHvCHoEU6ah_QteEruGhNRZ1by-dhwmCJ2yrDzY8F_MTwGrUYnXSok8aa0mRwlEqBdYZMTQ4Uo7PFpuA4ptw3j6KPS4Je2TziPE0Ebt3Bu5HIwZCF1IHQhdQD2GUyl039KgD7Pl1zaSeuIzk64c_p7NIfiZtCWSxgXP7FTVs4OVl7OVP9xPvNELzdlqeXZyjQ42Oh4s_fCjCAE6c_RpX77SXl5_m8M7SHrWI99TAhZAxbnF1pslDBGyGYIfwlvsTuusjYTvr8EDobm96jGNTKCZ0500bjtzFQaUOPaG7Tob9UBO6G7yrptCxUzIOnBxul5WE7qRu1CDivqoaJ6pmELwSeJANVuco65PorayMjyLqVZsQY9UU3fbo8EISK0eSqmr79MenzVNVwcFIAVVVu882EFrGUFZVURkx6ryamNTzOoycGb8o4WPwkGVlNHZK32MiLjqZi8MwOB1vaoyiPfefCS2r6uAx4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