@@ -24,7 +24,7 @@ be unsigned. The following cases all fall into the first category.
2424</p >
2525
2626<p >
27- Given <code >unsigned short n1, delta</code > and <code >n1 + delta < n1</code >,
27+ Given <code >unsigned short n1, delta</code > and <code >n1 + delta < n1</code >,
2828it is possible to rewrite it as <code >(unsigned short)(n1 + delta) < n1</code >.
2929Note that <code >n1 + delta</code > does not actually overflow, due to <code >int</code > promotion.
3030</p >
@@ -48,7 +48,7 @@ header has been included.
4848In the following example, even though <code >delta</code > has been declared
4949<code >unsigned short</code >, C/C++ type promotion rules require that its
5050type is promoted to the larger type used in the addition and comparison,
51- namely a <code >signed int</code >. Addition is performed on
51+ namely a <code >signed int</code >. Addition is performed on
5252signed integers, and may have undefined behavior if an overflow occurs.
5353As a result, the entire (comparison) expression may also have an undefined
5454result.
@@ -67,10 +67,10 @@ are avoided.
6767<sample src =" SignedOverflowCheck-good1.cpp" />
6868<p >
6969In the following example, even though both <code >n</code > and <code >delta</code >
70- have been declared <code >unsigned short</code >, both are promoted to
70+ have been declared <code >unsigned short</code >, both are promoted to
7171<code >signed int</code > prior to addition. Because we started out with the
7272narrower <code >short</code > type, the addition is guaranteed not to overflow
73- and is therefore defined. But the fact that <code >n1 + delta</code > never
73+ and is therefore defined. But the fact that <code >n1 + delta</code > never
7474overflows means that the condition <code >n1 + delta < n1</code > will never
7575hold true, which likely is not what the programmer intended. (see also the
7676<code >cpp/bad-addition-overflow-check</code > query).
0 commit comments