<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61957>61957</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Implement a check to remove redundant `return 0;` in main()
</td>
</tr>
<tr>
<th>Labels</th>
<td>
good first issue,
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kirillbobyrev
</td>
</tr>
</table>
<pre>
The [main function](https://en.cppreference.com/w/cpp/language/main_function) in C++ has the following property:
> 4) The body of the main function does not need to contain the [return statement](https://en.cppreference.com/w/cpp/language/return): if control reaches the end of main without encountering a return statement, the effect is that of executing `return 0;`.
Therefore, having `return 0;` in `main()` is just redundant. It would be best to remove the extra line as it reduces readability.
Note that for C, it is only true since C99 ([docs](https://en.cppreference.com/w/c/language/main_function)).
Implementing a check for it should be quite straightforward and can serve as a great learning ground for someone interested in contributing to LLVM/starting out.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVM-PozYU_mvM5WkiYkISDhw2mSKttO1p1Wtl7Ad41_hR-znZ_PeVYXamo44qVb2AZPF9_n4JFaMdPWIr6ouonwuVeKLQfrfBOtdT_wh4K3oyj_brhCDqy6yshyF5zZa8qJ-FPE_MSxTVJyE7ITv0O70sAQcM6DXuNM1CdnchO70sQnZO-TGpEYXsMtcfr1yyAevhKuRFyAtMKgJPCAM5R3frR1gCLRj4kW8qn0X581n9AocMzgKzUqBhRb5TCoYwgicGj2iACTR5zl_w5isgp-AhsmKc0fP_tLbRCdmI6hPYYb0tkIOASk-4WUNvstZV593yRIkBvabkGUN2rOAfquR1gw4DagabiRRnFvyBOnFGiWP5AitFdRHHcvf3uL5OGHCggJlqUrcPEbkIcSyzMiHP2UU-i_AtRYaAJnmjPO_gM8OdkjPQI_QYOecacKYbbip_cFDgrEdQEewG1RhzCkb11ll-vBP3GzFujgYKeQrXjLIRyLsHcEgI0XqNcG0ayMrqiyEd_2NX_z5CIZt3mj7Pi1uz3xrRE-rvqzzLEKef7v9MlhEiB2XHiQcKdxUMKG9AKw8Rw23NQMEYUDE4VMFnwjFQ8mblizQjeQSb68fIaHIN63Bsv1XLBF--_P6rkF1kFdYjSrwrTFuZpmpUge3-eC5PUh5Op2Jqe1Xpshn66iTP-lye9fHUazMcVL3Xqld1YVtZyqo8lPW-kfv9aadLhWY4lKj3WJ2PJ3EocVbW7Zy7zTsKY2FjTNge9019Kpzq0cX13yHlSGRgsCHmxmJCIaWQVyGlzmk_sTWPfFQ_F6HNbE99GqM4lM5Gjm_8bNlh-5r6a-Rv03od4MfDfVttkYJr389itDyl_mUN-c6X19MS6BtqFrJbxUchu9XjXwEAAP__acmzBA">