PR 25512: pointer overflow defined?
Gabriel Dos Reis
gdr@integrable-solutions.net
Wed Dec 21 18:49:00 GMT 2005
Paolo Carlini <pcarlini@suse.de> writes:
| 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...
I don't understand your query.
I understood Chris' comment as having to do with the implementation of
std::less<T*> (and friends) as required by C++. Our implementation is just
a forwarding function to operator< (and friends) on the assumption
that the compiler uses the "obvious" model.
-- Gaby
More information about the Gcc
mailing list