Sunday, October 10, 2010

Addresses of Zero Element Arrays

Given the following code:

      int *pInt1 = new int[0];
      int *pInt2 = new int[0];
      int *pInt3 = new int[0];

The following expression is true:

      ((pInt1 != pInt2) &&
       (pInt2 != pInt3) &&
       (pInt3 != pInt1)   )

This is described by the C++ standard.

Reference: More Exceptional C++ by Herb Sutter. Addison-Wesley, 2002., p. 177.

No comments:

Post a Comment