Skip to content

Commit a426412

Browse files
authored
Merge pull request #4497 from vadi2/patch-1
Add modern C++ variant
2 parents 4c5ecb4 + aa578ed commit a426412

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cpp/ql/src/Likely Bugs/Arithmetic/IntMultToLong.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ long j = i * i; //Wrong: due to overflow on the multiplication between ints,
44

55
long k = (long) i * i; //Correct: the multiplication is done on longs instead of ints,
66
//and will not overflow
7+
8+
long l = static_cast<long>(i) * i; //Correct: modern C++

0 commit comments

Comments
 (0)