Liste des Groupes | Revenir à c arch |
On Thu, 12 Sep 2024 04:04:06 -0700, Tim Rentsch
<tr.17687@z991.linuxsc.com> wrote:
>George Neuner <gneuner2@comcast.net> writes:
>I definitely am NOT an expert on the C standard, but thinking>
about it, it occurred to me that if an array is explicitly defined
that *might* cover all memory (or at least all heap), then the
compiler would have to honor any apparent pointers into it.
>
E.g., char (*all_memory)[] = 0;
This declaration introduces a pointer, not an array. Similarly
the declaration
>
char (*great_white_array)[ 999999999999999999 ] = 0;
>
does not introduce an array but just a pointer (and initializes
the pointer to be a null pointer). There is no humongous array.
Of course there is no actual array ... the point was to (try to)
define *something* such that the compiler would think there was an
array and consider any char* as possibly pointing to an element of
that array.
[And yes! it might end up pessimizing character manipulating code.]
>
The C standard guarantees that pointers to 2 elements of the same
array are comparable, and current (and past) compilers do allow
comparing arbitrary pointers when cast to char* without needing an
actual char array that covers the addresses.
>
But a guarantee wrt the standard requires the compiler to at least
*think* there is such an array. The question is how to do that.
Les messages affichés proviennent d'usenet.