C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Require diagnostic for array to bool conversion

From: sasho648 <sasho648_at_[hidden]>
Date: Sat, 22 Jul 2023 13:20:23 +0300
Yeah nice but pointer to bool may be useful while array to pointer to bool
never can.

On Sat, Jul 22, 2023 at 1:18 PM Giuseppe D'Angelo via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On 22/07/2023 10:39, sasho648 via Std-Proposals wrote:
> >
> > In my opinion such a conversion holds no value - since it has only one
> > outcome - and furthermore I think it's against C++ type safety - and
> > even furthermore I think currently it's only purpose is obfuscation
> > contests or creating hard to diagnose bugs as the case I've shown above.
>
> Technically speaking, a pointer to bool conversion is considered
> unconditionally narrowing since C++20
>
> https://eel.is/c++draft/dcl.init.list#7.5
>
> Your usage would still be legal (it's not list-init), but compilers or
> linters *could* warn about this. A quick test after: only MSVC warns and
> only under /Wall, clang-tidy doesn't even consider this possibility in
> its cppcoreguidelines-narrowing-conversions checker.
>
> https://gcc.godbolt.org/z/9a3b5WEbW
>
>
> My 2 c,
>
> --
> Giuseppe D'Angelo
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2023-07-22 10:20:35