Robert Dewar wrote:
> Richard Guenther wrote:
>
>> On Wed, 21 Dec 2005, Andrew Haley wrote:
>>
>>  
>>
>>> Richard Guenther writes:
>>> > > The problem in this PR is that code like in the testcase (from
>>> > OpenOffice) assumes that pointer overflow is defined.  As the
>>> > standard does not talk about wrapping pointer semantics at all (at
>>> > least I couldn't find anything about that), how should we treat
>>> > this?
>>>
>>> Look at Section 6.5.6, Para 8.  The code is undefined.
>>>   
>>
>> This talks about pointers that point to elements of an array object.
>> It does not talk about doing arithmetic on arbitrary pointer
>> (constants),
>> which is what the code does.
>>
> Right, but that's the point. "doing arithmetic on arbitrary pointer"
> values is
> not defined, it is not even defined to compare two pointers pointing
> to two
> different objects.
>
While that is true according to the standard, I believe that on most
systems you can compare any two pointers. In particular, the C++
standard does require a total ordering on pointers, and at the moment
that is implemented for all systems by just doing "a < b" on the two
pointers.

Chris

Reply via email to