C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: Fixing common reinterpret_cast design patterns
From: Lyberta (lyberta_at_[hidden])
Date: 2019-07-20 15:34:00


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




STD-DISCUSSION list run by herb.sutter at gmail.com

Older Archives on Google Groups