Type of comparisons and conditionals

  • Thread starter Frederick Gotham
  • Start date
V

Victor Bazarov

Jerry said:
[ ... ]
Right. I thought it's also OK to subtract two pointers if they
point to objects which are subobjects of the same object, but I just
checked and didn't find that. Strange.

$5.7/6: "Unless both pointers point to elements of the same array
object, or one past the last element of the array object, the
behavior is undefined."

Yes, and?
 
J

Jerry Coffin

Jerry said:
[ ... ]
Right. I thought it's also OK to subtract two pointers if they
point to objects which are subobjects of the same object, but I just
checked and didn't find that. Strange.

$5.7/6: "Unless both pointers point to elements of the same array
object, or one past the last element of the array object, the
behavior is undefined."

Yes, and?

And therefore, if they are subobjects of the same object (rather than
elements of the same array) the behavior is undefined.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top