C++ Logo

std-proposals

Advanced search

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

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Fri, 8 Sep 2023 10:16:09 +0100
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.

Received on 2023-09-08 09:16:22