Discussion:
Object storage vs Object Lifetime discrepancy
(too old to reply)
Staffan Tjernstrom
2018-11-21 17:21:49 UTC
Permalink
In [intro.object] [3] we see that storage for an object can be provided by
arrays of unsigned char or std::byte.

In [basic.life] [6.4] we see that it's allowed to observe the data in an
object's storage through pointers to cv char, cv unsigned char, or cv
unsigned byte (as long as we static_cast through void*).

If I read that strictly, that kind of implies that we're ok calling the
posix send() call (cv char *), but not the recvmsg call( cv char * ).

Non-exclusive questions that arise in my mind:

Is my understanding flawed (very likely)?

Should (signed) char be allowed to provide storage?

Should (signed) char be dropped from the allowed observation pointer types?

Does the discrepancy even matter?
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Language Lawyer
2018-11-21 17:35:49 UTC
Permalink
Post by Staffan Tjernstrom
In [intro.object] [3] we see that storage for an object can be provided by
arrays of unsigned char or std::byte.
In [basic.life] [6.4] we see that it's allowed to observe the data in an
object's storage through pointers to cv char, cv unsigned char, or cv
unsigned byte (as long as we static_cast through void*).
If I read that strictly, that kind of implies that we're ok calling the
posix send() call (cv char *), but not the recvmsg call( cv char * ).
I don't think that you're ok observing the value of the object storage through unsigned char.
For an object created not in the storage provided by an array, there is no way to get a pointer to char from pointer to object (see pointer-interconvertibility rules).
For an object created in storage provided by an array of char/bytes, you can't access the storage using a pointer to char derived from array (by array-to-pointer conversion + pointer arithmetic) because, even though the array providing storage is alive, its members (in the range occupied by the object) are dead and you're not allowed to read/write through a pointer to a dead object.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Continue reading on narkive:
Loading...