Overflow rule in two's complement arithmetic In the book by William Stallings the overflow rule overflow rule for 2's complement addition is stated as follows:


  Overflow rule: If two numbers are added, and they are both positive or both negative, then overflow occurs if and only if the result has the opposite sign.


Then the book gives the following examples:



Doubts:


If two numbers with the same sign are added, shouldn't the result have the same sign?  How can the result have an opposite sign (e.g., $+1+2=+3$ and $-1-2=-3$)?
Point 1 is reflected in the examples (d), (e) and (f). An overflow seem to occur in all of them  (though the word "Overflow" is not printed in example (d)), but the sign of the result is the same as that of operands.
Yes, if we are talking about integers. In two's complement representation with length $n$ you can only represent the integers between $-2^{n-1}$ and $2^{n-1} - 1$ (both bounds inclusive). Thus, the addition operation is not the same as the one over the integers—it is not even a proper operation because of overflows, which are left undefined; since it is a completely different operation, other rules apply (as I expect to have been previously mentioned in the book's text).
Do not mistake "overflow" for the result having a 1 carry at the left end. In example (b), for instance, the result of addition has such a carry, but it is truncated back to 4 bits, hence producing a correct result; the same happens in (d). However, an overflow occurs in both (e) and (f) because then the result is outside the representation range for 4-bit two's complement, that is, between $-2^{4-1} = -8$ and $2^{4-1} - 1 = 7$.