PR 25512: pointer overflow defined?

Robert Dewar dewar@adacore.com
Wed Dec 21 18:45:00 GMT 2005


Paolo Carlini wrote:

>chris jefferson wrote:
>
>  
>
>>>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.
>> 
>>
>>    
>>
>Humpf! Can people please cite exact paragraphs of the relevant
>Standards? Otherwise, I think we are just adding to the confusion. For
>example, in my reading of C99 6.5.9 and C++03 5.10 pointers *can* be
>compared for equality and discussing separately and correctly relational
>operators and equality operators is not a language-lawyer-ism, is *very*
>important for its real world implications. But this is only an example...
>
>Paolo.
>  
>
Surely pointers can be compared for equality (it is fine to see if a 
pointer is pointing
to something). The discussion about pointer comparison across objects is wrt
expecting any kind of ordering relationshiop.




More information about the Gcc mailing list