[PATCH] Warning for main returning a bool.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 15 10:17:28 PST 2016


On Fri, Oct 14, 2016 at 1:17 PM, Joshua Hurwitz via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
> See attached.
>
> Returning a bool from main is a special case of return type mismatch. The
> common convention when returning a bool is that 'true' (== 1) indicates
> success and 'false' (== 0) failure. But since main expects a return value of
> 0 on success, returning a bool is usually unintended.

I am not convinced that this is a high-value diagnostic. Returning a
Boolean from main() may or may not be a bug (the returned value is
generally a convention more than anything else). Also, why Boolean and
not, say, long long or float?

~Aaron

>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>


More information about the cfe-commits mailing list