Not-so-subtly Broken Code
Consider the following code, which is the first portion of a loop, assuming the existence of const vector<char>& buffer:
for (int i = 0; i < size_of_vector; i++) {
//getting delta from buffer
char c = buffer[n_byte_read/+i];
Although this code is well-formed, it is certain to crash, because of the division by the induction variable on the first iteration. What I find most amusing here is that the well-formedness of the code hinges on the unary plus operator1. Sadly, this particular landmine has been sitting in our code repository for around two years waiting to be stepped on, without anyone noticing until now.
-
To my knowledge, there is no use for the unary plus operator in its standard form. From a little research see that it can be used to trigger integral promotion, but that seems unlikely to ever be of much practical import. Also, crazy people (cough Boost Spirit cough) can overload it. ↩