Subject: Re: [std-proposals] Allowing access to object representations
From: Jake Arkinstall (jake.arkinstall_at_[hidden])
Date: 2019-08-22 02:17:38
On Thu, 22 Aug 2019, 02:06 sdkrystian via Std-Proposals, <
> > It does. But the char pointer points to the first byte. Which is
> platform dependant.
> Don't think so: "the pointer value is unchanged" means exactly what it
> says, it still points to the int object. It is not specified anywhere that
> it will point to any char object.
> > Which is a char.
> No, it is never specified that it points to any char object. It points to
> an int object.
You have a pointer some int. That int is multiple char widths long. You
create a pointer to a char and reinterpret cast the int pointer into a
pointer to char. It might truly be a pointer to int, but by this point
there is no way for any code accepting that char pointer to know that it is
truly a pointer to int, char, or an elephant, but that, for all intents and
purposes, it can be treated as a char. Dereferencing the char pointer
grants you one char representing the value of the leftmost byte of the
What in the above is incorrect?
Im asking specifically because what you're saying directly contradicts an
example provided at the bottom of
https://en.cppreference.com/w/cpp/language/reinterpret_cast, where a char
pointer to an int is dereferenced to determine the endianness of the system.
STD-PROPOSALS list run by herb.sutter at gmail.com
Standard Proposals Archives on Google Groups