On Sun, Nov 6, 2016 at 1:18 AM Michał Górny via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Fri, 14 Oct 2016 17:17:59 +0000
> Joshua Hurwitz via cfe-commits <cfe-commits@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:
>
>   return !foo;
>
> i.e. whenever user intentionally inverts a 'non-zero success' into 'zero
> success'.
>

I would imagine that not everybody's going to switch on that warning, but I
wouldn't consider this a false positive on !foo, mainly because it still
looks unclear whether the author thought about the semantics of the return
value.


>
> --
> Best regards,
> Michał Górny
> <http://dev.gentoo.org/~mgorny/>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to