C++: Add the example code for IntMultToLong to the test.

This commit is contained in:
Geoffrey White
2020-10-19 15:40:17 +01:00
parent 466c22f4a8
commit 6280b7d5d4
2 changed files with 4 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
int i = 2000000000;
long j = i * i; // BAD
long k = (long) i * i;

View File

@@ -12,3 +12,4 @@
| IntMultToLong.c:108:14:108:78 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'unsigned long'. |
| IntMultToLong.c:119:14:119:26 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'unsigned long'. |
| IntMultToLong.c:126:14:126:32 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'unsigned long'. |
| IntMultToLong.cpp:2:10:2:14 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'long'. |