Date: Mon, 21 Sep 2026 09:30:46 +0200
On Mon, Sep 21, 2026 at 9:22 AM Liam Graham via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> extra clarification: I understand type safety, but my position is about
> developer ergonomics.
>
> Why are we allowing X * to void * rather than making the developer cast?
> While void * to X * is somehow requiring the developer to cast? Double
> standards isn’t it? If you’re worried about type safety you would enforce
> explicit casting for both since both are different types!
>
> You either allow implicit conversion for both ends, or enforce explicit
> conversion for both ends. The double standards just confuses people!
>
No such thing. Converting from a typed pointer to an untyped one is a
conversion to a less capable more generic type, which is equivalent to
upcasting to an unknown base class. Upcasts are always ok if the base class
is correct - and in this case we have a "base class" of zero information,
so it's literally always fine.
Downcasting always requires a cast of sorts, whether from a T* to a U* or
from a void* to a U*. There's zero information to know that converting from
a T* or a void* to a U* is valid, so we need to have some force to make it
do that cast anyway, or a dynamic_cast if both T and U are polymorphic
types for a checked cast.
You need to re-read how type safety works. Your "double standards" reply
does not reflect understanding of basic narrowing and widening concepts.
std-proposals_at_[hidden]> wrote:
> extra clarification: I understand type safety, but my position is about
> developer ergonomics.
>
> Why are we allowing X * to void * rather than making the developer cast?
> While void * to X * is somehow requiring the developer to cast? Double
> standards isn’t it? If you’re worried about type safety you would enforce
> explicit casting for both since both are different types!
>
> You either allow implicit conversion for both ends, or enforce explicit
> conversion for both ends. The double standards just confuses people!
>
No such thing. Converting from a typed pointer to an untyped one is a
conversion to a less capable more generic type, which is equivalent to
upcasting to an unknown base class. Upcasts are always ok if the base class
is correct - and in this case we have a "base class" of zero information,
so it's literally always fine.
Downcasting always requires a cast of sorts, whether from a T* to a U* or
from a void* to a U*. There's zero information to know that converting from
a T* or a void* to a U* is valid, so we need to have some force to make it
do that cast anyway, or a dynamic_cast if both T and U are polymorphic
types for a checked cast.
You need to re-read how type safety works. Your "double standards" reply
does not reflect understanding of basic narrowing and widening concepts.
Received on 2026-09-21 07:31:02
