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,425 of 33,346    |
|    Francis Glassborow to Seungbeom Kim    |
|    Re: Casting from void*    |
|    27 Aug 11 05:56:41    |
      From: francis.glassborow@btinternet.com              On 27/08/2011 03:19, Seungbeom Kim wrote:       > 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