Re: When is it legal to compare any pair of pointers?

2005-09-15 Thread Alexandre Oliva
On Sep 14, 2005, Joe Buck [EMAIL PROTECTED] wrote: On Wed, Sep 14, 2005 at 02:15:43PM -0300, Alexandre Oliva wrote: Yep, it was pointer subtraction, and GCC actually optimized the division, that could in theory be assumed to be exact, into a multiplication by a large constant (aah, the

Re: When is it legal to compare any pair of pointers?

2005-09-14 Thread Alexandre Oliva
On Sep 13, 2005, Daniel Jacobowitz [EMAIL PROTECTED] wrote: This bit binutils, in the form of a crash in a hash function on Solaris. I think that was pointer subtraction, rather than comparison, however. Perhaps someone who remembers this problem more clearly than I do can chip in if I've

Re: When is it legal to compare any pair of pointers?

2005-09-14 Thread Joe Buck
On Wed, Sep 14, 2005 at 02:15:43PM -0300, Alexandre Oliva wrote: On Sep 13, 2005, Daniel Jacobowitz [EMAIL PROTECTED] wrote: This bit binutils, in the form of a crash in a hash function on Solaris. I think that was pointer subtraction, rather than comparison, however. Perhaps someone

Re: When is it legal to compare any pair of pointers?

2005-09-13 Thread Paolo Carlini
chris jefferson wrote: I realise that according to the C++ standard it isn't legal to compare two pointers which are not from the same array. Is anyone aware of anything in g++ which would actually forbid this, and if there is any way of checking if will be valid? In my opinion we should first

Re: When is it legal to compare any pair of pointers?

2005-09-13 Thread Paolo Carlini
Paolo Carlini wrote: Then, as far as *our* library (and compiler) are concerned, there is the interesting example of basic_string::_M_disjunct: with Nathan's substantive insight we came to the conclusion that such kind of comparisons can be always meaningful to do (at the C++ library level) if we

Re: When is it legal to compare any pair of pointers?

2005-09-13 Thread Daniel Jacobowitz
On Tue, Sep 13, 2005 at 11:22:18AM +0100, chris jefferson wrote: I realise that according to the C++ standard it isn't legal to compare two pointers which are not from the same array. Is anyone aware of anything in g++ which would actually forbid this, and if there is any way of checking if