Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Wojtek Lerch <wojtek_l@yahoo.ca> |
|---|---|
| Newsgroups | comp.std.c |
| Subject | Re: C11 6.3.2.3p7 Referenced Type |
| Date | 2013-01-06 22:13 -0500 |
| Message-ID | <akusqqFg0qhU1@mid.individual.net> (permalink) |
| References | <kc5v4n$ing$1@dont-email.me> <akppc6Favm8U1@mid.individual.net> <kfn1udxdbru.fsf@x-alumni2.alumni.caltech.edu> |
On 06/01/2013 8:25 PM, Tim Rentsch wrote:
> I believe there is no real doubt about how the committee expects
> the existing language should be read: when converting from type
> A* to type B*, if the first byte of the A object is suitably
> positioned in the addressing structure (as used in the A* pointer)
> so that an object of type B may begin there (under the appropriate
> addressing structure for B, given that the B* value is converted
> from the A* pointer), then the conversion will succeed with
> alignment requirements being satisfied;
I agree that that's probably what "everybody knows" is expected to
happen. But I really don't see where the standard says it.
> the object designated by
> the post-conversion pointer
There's not always a guarantee that the post-conversion pointer points
to an object (of its referenced type). There may not be enough memory
there. (But even if there isn't, the pointer conversion is still defined.)
> has the same first byte as the object
> designated by the pre-conversion pointer; and converting back and
> forth works, changing the types but preserving the same first byte
> property between the two objects (so first converting to (char *)
> or (void *) and then converting to the target type would give the
> same result as converting directly to the target type).
> Assuming there is general agreement that this basically is what
> the Standard is supposed to say, the question is how to say it
> in a way that can be used consistently with what all else the
> Standard says about alignment, but without tying the wording to
> any underlying addressing structure. I suspect that's not an
> easy proposition, which is why we have the somewhat convoluted
> wording describing how pointer conversions work, still, in C11.
First I would like to know whether the standard already says it or not.
Consider this simple example:
int main( void ) {
if ( _Alignof(int) <= _Alignof(float) ) {
float f;
int n, *p = (int*) &f;
if ( p == &n )
puts( "They're equal!" );
}
}
It this program produces output on some implementation, which
requirement of the standard does the implementation violate? (Chapter
and verse please.)
Back to comp.std.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-04 02:08 -0500
Re: C11 6.3.2.3p7 Referenced Type Keith Thompson <kst-u@mib.org> - 2013-01-04 08:09 -0800
Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-04 12:25 -0500
Re: C11 6.3.2.3p7 Referenced Type lawrence.jones@siemens.com - 2013-01-04 13:47 -0500
Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-04 14:56 -0500
Re: C11 6.3.2.3p7 Referenced Type lawrence.jones@siemens.com - 2013-01-04 17:10 -0500
Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-04 20:34 -0500
Re: C11 6.3.2.3p7 Referenced Type Wojtek Lerch <wojtek_l@yahoo.ca> - 2013-01-04 23:45 -0500
Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-05 02:07 -0500
Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-05 02:16 -0500
Re: C11 6.3.2.3p7 Referenced Type Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-06 17:25 -0800
Re: C11 6.3.2.3p7 Referenced Type Wojtek Lerch <wojtek_l@yahoo.ca> - 2013-01-06 22:13 -0500
Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-06 23:30 -0500
Re: C11 6.3.2.3p7 Referenced Type Wojtek Lerch <wojtek_l@yahoo.ca> - 2013-01-07 00:07 -0500
Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-07 01:29 -0500
Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-07 02:18 -0500
Re: C11 6.3.2.3p7 Referenced Type Wojtek Lerch <wojtek_l@yahoo.ca> - 2013-01-10 17:45 -0500
Re: C11 6.3.2.3p7 Referenced Type Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-06 22:30 -0800
Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-07 01:58 -0500
Re: C11 6.3.2.3p7 Referenced Type Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-06 23:16 -0800
Re: C11 6.3.2.3p7 Referenced Type Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-06 22:02 -0800
csiph-web