C++ Logo

std-proposals

Advanced search

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

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Mon, 11 Sep 2023 10:44:31 +0100
On Mon, Sep 11, 2023 at 5:04 AM Jens Maurer <jens.maurer_at_[hidden]> wrote:
>
> We generally don't specify warnings in the standard.
>
> Do you want to make a conversion from function to bool ill-formed,
> i.e. an error?
>
> If so, I think we need a little bit of analysis why this doesn't
> break a lot of existing code (if any) that (for better or worse)
> uses that conversion already.


It will only break buggy code, because there's no reason to check if a
function is true or false.

The Standard doesn't talk about 'weak' symbols but we would have to
accommodate them, something like:
    "Conversion from function to bool is ill-formed unless by a
proprietary compiler extension a function could possibly evaluate to
false".

Received on 2023-09-11 09:44:45