C++ Logo

std-discussion

Advanced search

Re: Fixing common reinterpret_cast design patterns

From: Lyberta <lyberta_at_[hidden]>
Date: Sat, 20 Jul 2019 20:34:00 +0000
sdkrystian via Std-Discussion:
> I have been working on some wording to change the following things with reinterpret_cast:- allow casting to char*, unsigned char* and std::byte* to access the object representation of an object, and- allow casting from char*, unsigned char* and std::byte* to an object pointer type T, where the pointer being casted is a pointer to an array or first element thereof providing storage to an object of type TThese are very common design patterns that are often used, and they currently have undefined behavior. I would like to get a sense of if this would be something that you all would like to see. Please provide any feedback or suggestions 😊
>
>

The first case is not UB:

https://stackoverflow.com/questions/16260033/reinterpret-cast-between-char-and-stduint8-t-safe


Received on 2019-07-20 15:36:16