Topic: P0298: A byte type definition: with undefined pointer arithmetic?
Author: Kazutoshi Satoda <k_satoda@f2.dion.ne.jp>
Date: Wed, 4 Jan 2017 19:43:05 +0900
Raw View
from P0298R2: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0298r2.pdf
> Motivation and Scope
> Many programs require byte-oriented access to memory. ...
Could you please show examples of such programs?
As I read N4623 (WG21 2016-11 Issaquah Minutes) and saw that the
proposal was about to pass through, I want to understand more concretely
what is going.
I suspect that such programs do something like obtaining unsigned char*
which points to an int object via reinterpret_cast and iterating through
it as if the pointer points to an element of unsigned char[sizeof(int)],
as I personally have seen many such programs.
However, AFAIK, the current standard doesn't (or fails to) give
well-defined behavior to such byte-oriented access on objects of
arbitrary types.
N4618 5.7 [expr.add] p6 says:
> For addition or subtraction, if the expressions P or Q have type
> "pointer to cv T", where T and the array element type are not similar
> (4.5), the behavior is undefined.
Then, if "Many programs require ..." is saying what I suspect, I think
defining such byte-oriented accesses should be done before (or within)
the proposal. It will also resolve CWG issue 1701:
"Array vs sequence in object representation"
http://wg21.cmeerw.net/cwg/issue1701
--
k_satoda
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e21a1901-1ed5-5795-6244-dd70c4d08adf%40f2.dion.ne.jp.
.