<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/86825>86825</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
flang/runtime/io-error.cpp:60: bad call to va_end ?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dcb314
</td>
</tr>
</table>
<pre>
Static analyser cppcheck says:
trunk/flang/runtime/io-error.cpp:60:11: error: va_list 'ap' used before va_start() was called. [va_list_usedBeforeStarted]
Source code is
if (msg && (flags_ & hasIoMsg)) {
#if !defined(RT_DEVICE_COMPILATION)
char buffer[256];
va_list ap;
va_start(ap, msg);
std::vsnprintf(buffer, sizeof buffer, msg, ap);
va_end(ap);
#else
const char *buffer = "not implemented yet: IOSTAT with varargs";
#endif
ioMsg_ = SaveDefaultCharacter(
buffer, Fortran::runtime::strlen(buffer) + 1, *this);
#if !defined(RT_DEVICE_COMPILATION)
va_end(ap);
#endif
}
It looks to me like the final call to va_end should be removed.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE2P4zYM_TXMhdjApuPYOfiQjzUQoNspmkGvgSLRtjqyZUhyFtNfX8jJdjJpC7Q6JBYpvkc-URTe63ZgriDfQX5YiCl01lVKXrJ0tbhY9V6dgghaohiEeffsUI6j7Fi-oRfvHrItJAdI7r_BTcMbUN0YMbRAtZuGoHsGqrX9ws5Zt5TjCNl2nUC2TVPItjib48dVnI32AYEKMQIVOHlWeOHGOo5OH4QLQCXQBr8Lj1IYw2qJkO_uoecYsZsDTvEwK8gPj_md7OQko7SKUftHD96XbhCo7H2LQGugddw1RrT-HA3YCX-033wLtIlpQLG7g1A2R6aKGz2wAip_fT0fvv523H8971--_XL8aft6fPk5xt34ZCccXqamYQf5jvJ1TDXbfc4G_xJFjP_s_CFKVGyP_S2zv5_0QcWryrZXP4xOD6EBKu_stEev_2Db4IdhBtpH1ke4qzjzoO5sH3agjI3nZ05pBx9udQJtb9gI2QGBaLABdT8a7nkIrPCdQ2yB48vpdfuK33Xo8CqccK0Hok9Eg9LNM5OOV3KesU_iygduxGTCvhNOyBALKp8j4vqotrYuODHcFPrRs_PGB2d4eNBqg0A7TGMU0DZ02j8p8T_b4PEu_03bh5Kh-NTPx4DG2jePwWLPaPQbY-gYGz0IMz-Q6LlBo-_sZOKDQse9vbJa3kAWqsrUJtuIBVdpkaZ5vi6LYtFVlHCjWBaKE5HzpuB0o1gmVK7LZiXKYqErSmiVZFSkayryYqk2glUik0IyZdlmBauEe6HN0phrv7SuXWjvJ67KdUn5wogLGz-PHqL7yKA4hVwVz3-5TK2HVRL7338gBB0MV_9twuBFqGcZIKsXkzNVF8I4zy-qgepWh266LKXtgerIdf_7Mjr7O8sQCWLqHqies_8zAAD__7L2inE">