Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 31,419 of 33,346    |
|    Seungbeom Kim to Seungbeom Kim    |
|    Re: Casting from void*    |
|    26 Aug 11 19:19:04    |
      From: musiphil@bawi.org              On 2011-06-28 12:12, Seungbeom Kim wrote:       > On 2011-06-27 11:02, A. McKenney wrote:       >>       >> By far the most common usage of       >> reinterpret_cast<> in the code I       >> work on is between (char *) and       >> (unsigned char *) (or their const       >> equivalents.)       >>       >> I consider this "practically portable",       >> because I am not aware of any       >> implementation where it would make       >> sense for the pointer representation to       >> differ between the signed and unsigned       >> versions.       >>       >> Can anyone conceive of an architecture where       >> a standard-conforming C++ implementation would       >> have any reason to use different representations       >> for signed char * and unsigned char *?       >       > I can't, especially when the standard guarantees that the three       > character types have the same object representation, including       > the same alignment requirements [3.9.1/1], and even that char*       > have the same representation and alignment requirements as void*       > [3.9.2/4].       >       > Why should char* be more closely related to void* than to signed char*       > or unsigned char*? Why doesn't the standard simply guarantee that the       > three character pointer types also have the same object representation,       > and that they can be converted by static_cast among one another?       >       > Assuming the status quo, is it correct that we have to go through void*       > to convert among the three character types, e.g.       >       > signed char* scp = /* ... */;       > unsigned char* ucp =       > static_cast |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca