C++ Logo

std-proposals

Advanced search

Re: [std-proposals] mandatory compiler diagnostic for converting function to boolean

From: Gašper Ažman <gasper.azman_at_[hidden]>
Date: Sat, 9 Sep 2023 09:03:15 +0100
Complain to your compiler vendor. The standard doesn't mandate diagnostics
for valid code. It's a good idea, but you're directing it at the wrong
people.

On Fri, Sep 8, 2023, 21:47 Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Today I discovered the following bug:
>
> if ( wxIsMainThread ) DoSomething();
>
> The bug here is that 'wxIsMainThread' is a function, and so it should have
> been:
>
> if ( wxIsMainThread() ) DoSomething();
>
> I think where we have a function converting to bool -- but not where
> we have a function pointer converting to bool -- the compiler should
> be mandated to issue a diagnostic.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2023-09-09 08:03:28