Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Shao Miller <sha0.miller@gmail.com> |
|---|---|
| Newsgroups | comp.std.c |
| Subject | Re: C11 6.3.2.3p7 Referenced Type |
| Date | 2013-01-05 02:07 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <kc8jfp$uk6$1@dont-email.me> (permalink) |
| References | <kc5v4n$ing$1@dont-email.me> <akppc6Favm8U1@mid.individual.net> |
On 1/4/2013 23:45, Wojtek Lerch wrote: > On 04/01/2013 2:08 AM, Shao Miller wrote: > ... > >> "A pointer to an object type may be converted to a pointer to a >> different object type. If the resulting pointer is not correctly >> aligned for the referenced type, the behavior is undefined. > > What I don't like about this wording (both old and new) is that it talks > about the alignment of the *resulting* pointer, even though the standard > does not generally specify what the result of the conversion is (other > than that it's a pointer that can be converted back; a few exceptions > include conversions to char*, between pointers to a struct and to the > type of its first member, etc.). Would it be wrong to say, instead, > that the behaviour is undefined if the *original* pointer, the one > before the conversion, is not correctly aligned for the type referenced > by the type of the result? Or to say, separately, that if the original > pointer satisfies the alignment requirements of some type, then the > converted pointer satisfies them too? > > Or maybe even that the converted pointer points at the same byte in > memory than the original pointer did (using some more formal wording)? > I've seen claims that this follows from some other requirements of the > standard (C99 at the time), but I never managed to find them. > Agreed. That was part of the discussion I had yesterday or so... My interpretation is that it means: "A pointer to an object type may be converted to a pointer to a different object type. If the resulting pointer does not address storage that is correctly aligned for the referenced type of the converted pointer type, the behavior is undefined. ..." C99 was a touch clearer, in my opinion, because it's not intuitive (to me, at least) that the _result_'s alignment requirement should have anything at all to do with "the pointed-to type", at least in part because it's at least sometimes an rvalue (whose alignment requirement doesn't seem intuitive to care about). So I make the leap from: "A pointer to an object or incomplete type may be converted to a pointer to a different object or incomplete type. If the resulting pointer is not correctly aligned57) for the pointed-to type, the behavior is undefined. ..." to: "A pointer to an object or incomplete type may be converted to a pointer to a different object or incomplete type. If the resulting pointer does not address storage that is correctly aligned57) for the pointed-to type of the converted pointer type, the behavior is undefined. ..." A bit of a boggle, to be sure. - Shao Miller
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