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 33,053 of 33,346    |
|    =?ISO-8859-1?Q?=D6=F6_Tiib?= to James K. Lowden    |
|    Re: compilers, endianness and padding    |
|    17 May 13 02:55:53    |
      From: ootiib@hot.ee              On Thursday, 16 May 2013 15:47:52 UTC+3, James K. Lowden wrote:       > Every pointer -- static, free store, or automatic -- always has some       > number of bytes allocated to it. (That number might be zero.)              That is in very limited meaning of "every". There are pointers that       point at sub-objects of other objects, pointers that point at elements       in containers or arrays and pointers that point at one past last       elements of arrays. Such might need to be serialized as well.              > The language deficiency is that it does not make that information       > available to the programmer.              It often lacks that information. It is up to programmer to bind all       the information that he needs into properties of types or objects from       what he designs the software. Several such types (with more       information bound around pointers) are readily available in standard       library (like containers, iterators or smart pointers). A 'char*' or       'void*' can point almost anywhere and be valid doing so. So programmer       must know what it is if he uses those.              > Instead, it requires the programmer to track it independently and       > duplicatively. And often, it might be noted, incorrectly.              Current C++ may be used without declaring any raw pointers, never       using keyword 'delete' and using keyword 'new' only to initialize       unique_ptr. Even that because C++11 forgot to add 'make_unique' that       will likely be added by C++14. It might be inconvenient or inefficient       at places but it can be used like that. So it can't be said that C++       requires programmers to track pointers. It is purely matter of free       will at the moment.              > Someone will object that keeping track of the size of memory       > allocated to a pointer will add 8 bytes to every pointer. Not true!       > Remember, every time you say       >       > char *s = "hello";       >       > the compiler set aside those 6 bytes and placed the next variable       > *after* them.              I don't think so. That 's' may be made to point into middle of some       "yellohello" in read-only memory since observable behavior must be       stays same.                     --        [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca