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: Sun, 10 Sep 2023 18:59:18 +0100
Yeah, I had a whole write-up about it above, but some people don't listen.

On Sun, Sep 10, 2023 at 5:41 PM Tom Honermann via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On 9/8/23 5:16 AM, Frederick Virchanza Gotham via Std-Proposals 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.
>
> The standard is only able to specify that a diagnostic is produced for a
> ill-formed program and even then, the actual diagnostic issued is a
> matter of QoI; a conforming implementation can emit "😭" as its
> diagnostic. What you are effectively asking for is to make the code
> above ill-formed.
>
> Tom.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2023-09-10 17:59:30