This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: malloc attributes and realloc


Kai Henningsen wrote:
dewar@gnat.com (Robert Dewar) wrote on 02.01.04 in <3FF544C5.9080706@gnat.com>:


It is indeed interesting that pointer ordering is not guaranteed by
the standard.

False. *Generic* pointer ordering is not supported; ordering of pointers to the same object certainly *is* supported.

We seem to have a quantification problem here :-)


I say,

it is not true that for all pointers, pointer ordering is guaranteed

You reply

that's false, it is guaranteed for some pointers!

You are most certainly not disagreeing with me, and you don't mean
to say False. Yes, of course we all know that pointer ordering is
guaranteed within an object (that's a very fundamental part of
C style, actually what's guaranteed is a bit more than this, since
you can do pointer comparison on the pointer just *past* an array
which of course is not a "pointer to the same object").

The point is that in general you cannot compare two pointers. That's
what pointer ordering means, it means that any two pointers have a
defined ordering.

Now as we have discussed in this thread, general pointer ordering is
extremely useful, for example if you are building hash tables of objects
and you want to sort hash chains by ascending pointers, or sort pointers
and do a binary search etc.

It seems likely that a lot of C code depends on this ability, and if
GCC can formally guarantee it, that's probably a good idea, and it is
hard to believe there is much optimziation cost associated with this
"extension".



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]