Oh! Just realized - I totally overlooked that. You're totally right, it would be UB under the current rules - could just add a special case for char, unsigned char and std::byte.



Sent from my Samsung Galaxy smartphone.

-------- Original message --------
From: Language Lawyer via Std-Proposals <std-proposals@lists.isocpp.org>
Date: 8/17/19 20:12 (GMT-05:00)
To: std-proposals@lists.isocpp.org
Cc: Language Lawyer <language.lawyer@gmail.com>
Subject: Re: [std-proposals] Allowing access to object representations

ok, never mind...

On 18/08/2019 03:06, sdkrystian via Std-Proposals wrote:
> Yes, since the object representation is considered to be an array containing the elements of the object representations.
>
>
>
> Sent from my Samsung Galaxy smartphone.
>
> -------- Original message --------
> From: Language Lawyer via Std-Proposals <std-proposals@lists.isocpp.org>
> Date: 8/17/19 20:04 (GMT-05:00)
> To: std-proposals@lists.isocpp.org
> Cc: Language Lawyer <language.lawyer@gmail.com>
> Subject: Re: [std-proposals] Allowing access to object representations
>
> On 18/08/2019 03:02, sdkrystian via Std-Proposals wrote:
>  > That has no effect, the array is an array of unsigned char objects, so a pointer arithmetic applied to a element of it is well within the rules.
>
> Using a pointer of type "pointer to char" to do arithmetic would be well within the rules?
>
>  > Sent from my Samsung Galaxy smartphone.
>  >
>  > -------- Original message --------
>  > From: Language Lawyer via Std-Proposals <std-proposals@lists.isocpp.org>
>  > Date: 8/17/19 19:59 (GMT-05:00)
>  > To: std-proposals@lists.isocpp.org
>  > Cc: Language Lawyer <language.lawyer@gmail.com>
>  > Subject: Re: [std-proposals] Allowing access to object representations
>  >
>  > https://timsong-cpp.github.io/cppwp/n4659/expr.add#6
>  >
>  > On 18/08/2019 02:49, sdkrystian via Std-Proposals wrote:
>  >  > unsigned char.
>  >  >
>  >  >
>  >  >
>  >  > Sent from my Samsung Galaxy smartphone.
>  >  >
>  >  > -------- Original message --------
>  >  > From: Language Lawyer via Std-Proposals <std-proposals@lists.isocpp.org>
>  >  > Date: 8/17/19 19:46 (GMT-05:00)
>  >  > To: std-proposals@lists.isocpp.org
>  >  > Cc: Language Lawyer <language.lawyer@gmail.com>
>  >  > Subject: Re: [std-proposals] Allowing access to object representations
>  >  >
>  >  > On 18/08/2019 02:42, sdkrystian via Std-Proposals wrote:
>  >  >  > You're right, there wouldn't be unless I specified that the object representation is considered to be an array
>  >  >
>  >  > Array of which type???
>  >  >
>  >  >  > Sent from my Samsung Galaxy smartphone.
>  >  >  >
>  >  >  > -------- Original message --------
>  >  >  > From: Language Lawyer via Std-Proposals <std-proposals@lists.isocpp.org>
>  >  >  > Date: 8/17/19 18:58 (GMT-05:00)
>  >  >  > To: std-proposals@lists.isocpp.org
>  >  >  > Cc: Language Lawyer <language.lawyer@gmail.com>
>  >  >  > Subject: Re: [std-proposals] Allowing access to object representations
>  >  >  >
>  >  >  > You propose:
>  >  >  >  > Insert a new paragraph below [expr.reinterpret.cast] p6
>  >  >  >  > A prvalue v of object pointer type "pointer to cv1 T1" pointing to an object a can be explicitly converted to an object pointer of a different type "pointer to cv2 T2", where cv2 is the same cv-qualification as, or greater cv-qualification than cv1, the result of which is defined as follows:
>  >  >  >  > — f T1 is a contiguous-layout type and T2 is unsigned char, char or std::byte, the result is a pointer to the first element of the object representation of a.
>  >  >  >
>  >  >  > Is there much sense in specifying casts to `char` or `std::byte` as giving a pointer to the first element of the object representation?
>  >  >  > You won't be able to use it for pointer arithmetic.
>  >  >  > --
>  >  >  > Std-Proposals mailing list
>  >  >  > Std-Proposals@lists.isocpp.org
>  >  >  > https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>  >  >  >
>  >  > --
>  >  > Std-Proposals mailing list
>  >  > Std-Proposals@lists.isocpp.org
>  >  > https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>  >  >
>  > --
>  > Std-Proposals mailing list
>  > Std-Proposals@lists.isocpp.org
>  > https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>  >
> --
> Std-Proposals mailing list
> Std-Proposals@lists.isocpp.org
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals