[PATCH] Warning for main returning a bool.
Michał Górny via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 6 01:18:03 PDT 2016
On Fri, 14 Oct 2016 17:17:59 +0000
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.
This triggers a false positive if you use a boolean expression like:
i.e. whenever user intentionally inverts a 'non-zero success' into 'zero
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 931 bytes
Desc: OpenPGP digital signature
More information about the cfe-commits