<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/121174>121174</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] Check request: modernize-use-stoi-instead-atoi
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
denzor200
</td>
</tr>
</table>
<pre>
```
std::string str = "42";
int a = std::atoi(str.c_str()); // INCORRECT
int b = std::stoi(str); // OK
```
Since `std::atoi` is ancient and might produce bugs in overflow cases.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxUkdGL2zAMxv8a5cUkqHKSpg9-yF1XGIMd3PY-HEdLvKX2zXI67v76kVJuVxAYjL5Pn36yIn4KzAaaB2iOhV3zHJMZObzFRIjFEMdXAy3eCnvJI-gedC85-TApyUmBPiogqgmIQD8A9j5kZa__7_02Rw_USU6V-yE5AXVAh630gwI6AZ3U56-PT8_Pnx6_3yyGewt5t7iXqacvgP3HlN98cKygxfvxLSovygbneQsYRnX205zVS4rj6lgN6yTKBxUvnH4u8a9yVliqYjR6POiDLdjs9rqhtsGOitm4zraoO1u32LWsG4uIB9s1NdquI6bCG0Kqd0R7JKxrqjoamBzu9Z4PPDiGGvls_VIty-VcxTQVXmRls6Pdbl8Xix14ket1iNxiw1RmP75unJtjkcymKrfUUOPiJct_n-zzcr3rB1lzVI8zu98q8Z-VJYPu1TmOnIJ_43IVLjfEpQ-S2Y7lxqxY02LmnF9k43jlPfk8r0Pl4hnotM27PeVLir_YZaDTdQkBOt32uBj6FwAA___jIbr5">