Result of some pointer comparisons

suggest change

If two pointers are compared using \<, \>, <=, or >=, the result is unspecified in the following cases:

int x;
  int y;
  const bool b1 = &x < &y;            // unspecified
  int a[10];
  const bool b2 = &a[0] < &a[1];      // true
  const bool b3 = &a[0] < &x;         // unspecified
  const bool b4 = (a + 9) < (a + 10); // true
                                      // note: a+10 points past the end of the array
class A {
  public:
    int x;
    int y;
    bool f1() { return &x < &y; } // true; x comes before y
    bool f2() { return &x < &z; } // unspecified
  private:
    int z;
};

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Unspecified behavio:
* Result of some pointer comparisons

Table Of Contents
8 Arrays
11 Loops
39 Streams
51 Unions
56 Lambdas
60 SFINAE
62 RAII
67 Sorting
84 RTTI
87 Scopes
100 Unspecified behavio
104 Profiling
107 Recursion
117 Iteration
125 Alignment
134 Semaphore
136 Debugging
139 Mutexes
142 decltype