C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Std-Proposals Digest, Vol 90, Issue 27

From: Simon Schröder <dr.simon.schroeder_at_[hidden]>
Date: Mon, 21 Sep 2026 11:49:24 +0200
Upcasting is necessary for proper object-oriented programming. It's the
Liskov substitution principle. It would be quite tedious to write OO code
if implicit casting wouldn't be allowed in this specific case.

On Mon, Sep 21, 2026 at 9:34 AM Liam Graham via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> it’s all about ergonomics. Yes type safety going X * to void * fine on
> paper because you’re throwing away information but in C++ void * and X *
> are considered different types. void is a different base type than X is.
> Reflect the type change by allowing explicit casting, not this weird half
> way implicit casting process. If you want type safety, C++ should reject
> implicit casting altogether, recognise both are different types and force
> the programmer to explicitly recognise and acknowledge the type change.
>
> Sent from Outlook for iOS <https://aka.ms/o0ukef>
> ------------------------------
> *From:* Peter Bindels <dascandy_at_[hidden]>
> *Sent:* Monday, 21 September 2026 08:30:46
> *To:* std-proposals_at_[hidden] <std-proposals_at_[hidden]>
> *Cc:* Liam Graham <liamgraham_at_[hidden]>
> *Subject:* Re: [std-proposals] Std-Proposals Digest, Vol 90, Issue 27
>
>
>
> 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 mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2026-09-21 09:50:07