SlideShare a Scribd company logo
1 of 106
Typical errors in code on the example of
C++, C#, and Java
Information Technology Video Developer Network
Информационный
видеосервис
для
разработчиков
программного
обеспечения
http://itvdn.com
Георгий Грибков
About the speaker
Information Technology Video Developer Network http://itvdn.com
ITVDN
C++ developer of the PVS-Studio static code analyzer
• Develops the analyzer core, new diagnostics, supports users.
• Introduced PVS-Studio in the godbolt.org online compiler.
• Wrote articles for the Habr website and gave talks at IT conferences,
related to searching for bugs in code.
Typical errors in code on the example of C++, C#, and Java
Agenda
Information Technology Video Developer Network http://itvdn.com
ITVDN
1. Objectives of this webinar
2. How we detected error patterns
3. Patterns themselves and how to avoid them:
3.1 Copy-paste and last line effect
3.2 if (A) {...} else if (A)
3.3 Errors in checks
3.4 Array index out of bounds
3.5 Operator precedence
3.6 Typos that are hard to spot
4. How to use static analysis properly
5. Conclusion
6. Q&A
Заключение
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
More than 50 video courses for C# developers at ITVDN
C# Basics
Author: Alexander Shevchuk
Duration: 16 h 3 mins
9 lessons
C# Basic (OOP)
Author: Alexander Shevchuk
Duration: 31 h 26 mins
18 lessons
C# for professionals
Author: Oleg Kulygin
Duration: 19 h 38 mins
17 lessons
C# Generics
Author: Nikolay Melnichuk
Duration: 4 h 49 mins
7 lessons
Unit testing in C#
Author: Dmitry Okhrimenko
Duration: 3 h 48 mins
3 lessons
.NET Apps
Refactoring
Author: David Boyarov
Duration: 6 h 41 mins, 5 lessons
Information Technology Video Developer Network http://itvdn.com
ITVDN
More than 26 video courses for Java developers at ITVDN
Java Starter
Author: Evgeny Tikhonov
Duration: 9 h 46 mins
9 lessons
Java Essential
Author: Evgeny Tikhonov
Duration: 11 h 10 mins
10 lessons
Java Professional
Author : Evgeny Tikhonov
Duration: 20 h 18 mins
15 lessons
SOLID principles in Java
Author: Andrey Fok
Duration: 2 h 45 mins
5 lessons
Unit testing in Java with JUnit
Author: Mikhail Skafenko
Duration: 2 h 33 mins
7 lessons
Java EE Basics
Author: Andrey Bondarenko
Duration: 18 h 50 mins
12 lessons
Information Technology Video Developer Network http://itvdn.com
ITVDN
Video courses for C++ developers at ITVDN
C++ Starter
Author: Vladimir Vinogradov
Duration: 8 h 13 mins
13 lessons
QT Framework
Author: Ruslan Larionenko
Duration: 6 h 27 mins
10 lessons
C++ Essential
Author: Kirill Chernega
Duration: 4 h 38 mins
8 lessons
C++Advanced
Author: Kirill Chernega
Duration: 8 h 17 mins
11 lessons
Complete practical tasks in C++
Author: Naumenko Alexander
Duration: 4 h 39 mins, 7 lessons
STL - Standard Template Library
Author: Pavlenko Alexander
Duration: 7 h 5 mins, 12 lessons
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
*
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
BUGS ARE EVERYWHERE!
Typical errors in code on the example of C++, C#, and Java
How to avoid errors
Information Technology Video Developer Network http://itvdn.com
ITVDN
• Warn developers of typical problems
• Use tools to automatically search for errors
Typical errors in code on the example of C++, C#, and Java
Objectives of this webinar
Information Technology Video Developer Network http://itvdn.com
ITVDN
• Demonstrate typical error patterns in code
• Show how to use static analysis properly
Typical errors in code on the example of C++, C#, and Java
2. How we detected error patterns
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
What is static analysis
Information Technology Video Developer Network http://itvdn.com
ITVDN
Static analysis is automated code review.
Typical errors in code on the example of C++, C#, and Java
What is static analysis
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Examples of static analyzers
Information Technology Video Developer Network http://itvdn.com
ITVDN
• PVS-Studio
• Cppcheck
• Infer
• IntelliJ IDEA
• Clang Static Analyzer
• FindBugs
• ...
Long list of static analyzers:
Typical errors in code on the example of C++, C#, and Java
How we detected error patterns
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Found errors
380 13747
Checked
projects
Detected
errors
Check out the base of errors we found:
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
3. Patterns themselves and how to avoid them
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Pattern № 1:
Copy-paste and last line effect
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Elasticsearch (Java)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Elasticsearch (Java)
Information Technology Video Developer Network http://itvdn.com
ITVDN
PVS-Studio warning:
V6039 There are two 'if' statements with identical
conditional expressions. The first 'if' statement
contains method return. This means that the
second 'if' statement is senseless.
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
Clang (C++)
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
Clang (C++)
PVS-Studio warning: V501 There are identical sub-expressions
SM.getExpansionColumnNumber(ContainerREnd)' to the left and to the right of the '>=' operator.
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
Clang (C++)
PVS-Studio warning: V501 There are identical sub-expressions
SM.getExpansionColumnNumber(ContainerREnd)' to the left and to the right of the '>=' operator.
Typical errors in code on the example of C++, C#, and Java
Xenko Game Engine (C#)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Xenko Game Engine (C#)
Information Technology Video Developer Network http://itvdn.com
ITVDN
PVS-Studio warning: V3001 There are
identical sub-expressions 'box.Maximum.X
- box.Minimum.X > sphere.Radius' to the
left and to the right of the '&&' operator.
Typical errors in code on the example of C++, C#, and Java
Pattern № 1: Copy-paste and last line effect
Information Technology Video Developer Network http://itvdn.com
ITVDN
• We selected 84 examples of erroneous code
written with copy-paste
• 43 of them had an error in the last line!
• It is more than 50%!
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
• Stop copy-pasting
• Copy-pasting in programming is pure evil!
• If you dare to – be extremely attentive
How to avoid
Typical errors in code on the example of C++, C#, and Java
Pattern № 2.
if (A) {...} else if (A)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Elasticsearch (Java)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Elasticsearch (Java)
Information Technology Video Developer Network http://itvdn.com
ITVDN
PVS-Studio warning:
V6003 The use of 'if (A) {....} else if (A)
{....}' pattern was detected. There is a
probability of logical error presence.
Typical errors in code on the example of C++, C#, and Java
Chromium (C++)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Chromium (C++)
Information Technology Video Developer Network http://itvdn.com
ITVDN
PVS-Studio warning:
V517 The use of 'if (A) {...} else if (A)
{...}' pattern was detected. There is a
probability of logical error presence.
Check lines: 61, 63.
Typical errors in code on the example of C++, C#, and Java
CryEngine V (C++)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
CryEngine V (C++)
Information Technology Video Developer Network http://itvdn.com
ITVDN
PVS-Studio warning:
V517 The use of 'if (A) {...} else if (A)
{...}' pattern was detected. There is a
probability of logical error presence.
Check lines: 266, 268.
Typical errors in code on the example of C++, C#, and Java
CryEngine V (C++)
Information Technology Video Developer Network http://itvdn.com
ITVDN
PVS-Studio warning:
V517 The use of 'if (A) {...} else if (A)
{...}' pattern was detected. There is a
probability of logical error presence.
Check lines: 266, 268.
Typical errors in code on the example of C++, C#, and Java
MonoDevelop (C#)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
MonoDevelop (C#)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
MonoDevelop (C#)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
MonoDevelop (C#)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
MonoDevelop (C#)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
MonoDevelop (C#)
Information Technology Video Developer Network http://itvdn.com
ITVDN
PVS-Studio warning:
V3021 There are two 'if' statements
with identical conditional
expressions. The first 'if' statement
contains method return. This means
that the second 'if' statement is
senseless.
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
• Try to do best not to copy-paste
• If you’re still going to copy-paste, copy non-compiled constructions.
• Example:
if (value == _)
return _;
How to avoid?
Typical errors in code on the example of C++, C#, and Java
Pattern № 3.
Errors in checks
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Unity (C#)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Unity (C#)
Information Technology Video Developer Network http://itvdn.com
ITVDN
PVS-Studio warning:
V3063 A part of conditional
expression is always true if it is
evaluated: pageSize <= 1000.
Typical errors in code on the example of C++, C#, and Java
Bullet - the engine of Red Dead Redemption (C++)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Bullet - the engine of Red Dead Redemption (C++)
Information Technology Video Developer Network http://itvdn.com
ITVDN
PVS-Studio warning:
V709 Suspicious comparison found:
'f0 == f1 == m_fractureBodies.size()’.
Remember that
'a == b == c’
is not equal to
'a == b && b == c'.
Typical errors in code on the example of C++, C#, and Java
Apache Hive (Java)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Apache Hive (Java)
Information Technology Video Developer Network http://itvdn.com
ITVDN
PVS-Studio warning: V6030 The method located to the right of the '|' operator will be called regardless of
the value of the left operand. Perhaps, it is better to use '||'.
Typical errors in code on the example of C++, C#, and Java
Chromium (C++)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Chromium (C++)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Chromium (C++)
Information Technology Video Developer Network http://itvdn.com
ITVDN
PVS-Studio warnings:
 V547 Expression
'time.month <=
kDaysInMonth[time.month] + 1' is
always true.
 V547 Expression
'time.month <=
kDaysInMonth[time.month]’
is always true.
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
• «Pay attention!» won’t work every time 
• Try backup tools
How to avoid
Typical errors in code on the example of C++, C#, and Java
Pattern № 4.
Array index out of bounds
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Stickies (C++)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Stickies (C++)
Information Technology Video Developer Network http://itvdn.com
ITVDN
PVS-Studio warning:
V557 Array overrun is possible. The
'64' index is pointing beyond array
bound. stickies stickies.cpp
Typical errors in code on the example of C++, C#, and Java
Elasticsearch (Java)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Elasticsearch (Java)
Information Technology Video Developer Network http://itvdn.com
ITVDN
PVS-Studio warning: V6025 Possibly index '(int) x' is out of bounds.
Typical errors in code on the example of C++, C#, and Java
Elasticsearch (Java)
Information Technology Video Developer Network http://itvdn.com
ITVDN
PVS-Studio warning: V6025 Possibly index '(int) x' is out of bounds.
Typical errors in code on the example of C++, C#, and Java
IPP Samples (C++)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
IPP Samples (C++)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
IPP Samples (C++)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
IPP Samples (C++)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
IPP Samples (C++)
Information Technology Video Developer Network http://itvdn.com
ITVDN
PVS-Studio warning:
V557 Array overrun is possible. The '30'
index is pointing beyond array bound.
Typical errors in code on the example of C++, C#, and Java
FastReport (C#)
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
FastReport (C#)
Information Technology Video Developer Network http://itvdn.com
ITVDN
PVS-Studio warning:
V3106 Possible negative index value. The value
of 'idx' index could reach -1.
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
• Be careful when you add '0’ to the end of the string
• Do you get an external index? Make sure you check it!
• Don’t mix up '>' ('<‘) and '>=' ('<=‘) when comparing the index with the array size
How to avoid
Typical errors in code on the example of C++, C#, and Java
4. How to use static analysis properly
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
When you should perform static analysis
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
When you should perform static analysis
Information Technology Video Developer Network http://itvdn.com
ITVDN
Static analysis
Typical errors in code on the example of C++, C#, and Java
How to make the most of static analysis
Information Technology Video Developer Network http://itvdn.com
ITVDN
• Apply static analysis at early stages
• Analyze regularly
Typical errors in code on the example of C++, C#, and Java
Proprietary development
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Proprietary development
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Proprietary development
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Proprietary development
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Proprietary development
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Corporate development
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Corporate development
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Corporate development
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Corporate development
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Corporate development
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Corporate development
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Corporate development
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Open-source development
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Open-source development
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Open-source development
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Open-source development
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
More about analysis of commits and pull-requests
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
5. Conclusion
Information Technology Video Developer Network http://itvdn.com
ITVDN
Typical errors in code on the example of C++, C#, and Java
Typical error patterns in code
Information Technology Video Developer Network http://itvdn.com
ITVDN
• Copy-paste and last line effect
• if (A) {...} else if (A)
• Errors in checks
• Array index out of bounds
• … (the list gradually expands)
Typical errors in code on the example of C++, C#, and Java
How to avoid typical errors
Information Technology Video Developer Network http://itvdn.com
ITVDN
• Stop copy-pasting!
• Seriously, stop copy-pasting!
• Pay attention to checks, even small and short ones.
• Carefully check array indexes.
• Regularly use static analysis.
Typical errors in code on the example of C++, C#, and Java
Free PVS-Studio license for students
Information Technology Video Developer Network http://itvdn.com
ITVDN
https://bit.ly/pvs-student
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
Q&A
Typical errors in code on the example of C++, C#, and Java
Information Technology Video Developer Network http://itvdn.com
ITVDN
Watch our video lessons on C++
At ITVDN you’ll find a collection of video courses and webinars for C++ developers.
Go to ITVDN.com and watch our video lessons right now!
IT VIDEO DEVELOPERS NETWORK
Information Technology Video Developer Network http://itvdn.com
ITVDN

More Related Content

Similar to Typical errors in code on the example of C++, C#, and Java

All about PVS-Studio
All about PVS-StudioAll about PVS-Studio
All about PVS-StudioPVS-Studio
 
PVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codePVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codeAndrey Karpov
 
Firmware Co-Design & Development for IP Cores in C++/SystemC using Verilator
Firmware Co-Design & Development for IP Cores in C++/SystemC using VerilatorFirmware Co-Design & Development for IP Cores in C++/SystemC using Verilator
Firmware Co-Design & Development for IP Cores in C++/SystemC using VerilatorSeyed Amir Alavi
 
Production Debugging at Code Camp Philly
Production Debugging at Code Camp PhillyProduction Debugging at Code Camp Philly
Production Debugging at Code Camp PhillyBrian Lyttle
 
From V8 to Modern Compilers
From V8 to Modern CompilersFrom V8 to Modern Compilers
From V8 to Modern CompilersMin-Yih Hsu
 
Developer-Friendly CI / CD for Kubernetes
Developer-Friendly CI / CD for KubernetesDeveloper-Friendly CI / CD for Kubernetes
Developer-Friendly CI / CD for KubernetesDevOps Indonesia
 
Waiting for a cyber range exercise is not enough
Waiting for a cyber range exercise is not enoughWaiting for a cyber range exercise is not enough
Waiting for a cyber range exercise is not enoughOlafSchwarz1
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programmingmaznabili
 
How I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScriptHow I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScriptKevin Read
 
Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8Kevin Read
 
Profiling distributed Java applications
Profiling distributed Java applicationsProfiling distributed Java applications
Profiling distributed Java applicationsConstantine Slisenka
 
Static analysis as means of improving code quality
Static analysis as means of improving code quality Static analysis as means of improving code quality
Static analysis as means of improving code quality Andrey Karpov
 
Letter to a Junior Developer: The Engineering Side of Programming
Letter to a Junior Developer: The Engineering Side of ProgrammingLetter to a Junior Developer: The Engineering Side of Programming
Letter to a Junior Developer: The Engineering Side of ProgrammingLazar Kovacevic
 
Continuous Delivery for IT Operations Teams
Continuous Delivery for IT Operations TeamsContinuous Delivery for IT Operations Teams
Continuous Delivery for IT Operations TeamsMark Rendell
 
OpenCV (Open source computer vision)
OpenCV (Open source computer vision)OpenCV (Open source computer vision)
OpenCV (Open source computer vision)Chetan Allapur
 
Be armed to the teeth to maintain a high quality iOS code
Be armed to the teeth to maintain a high quality iOS codeBe armed to the teeth to maintain a high quality iOS code
Be armed to the teeth to maintain a high quality iOS codeAnastasia Kazakova
 
[RHFSeoul2017]6 Steps to Transform Enterprise Applications
[RHFSeoul2017]6 Steps to Transform Enterprise Applications[RHFSeoul2017]6 Steps to Transform Enterprise Applications
[RHFSeoul2017]6 Steps to Transform Enterprise ApplicationsDaniel Oh
 

Similar to Typical errors in code on the example of C++, C#, and Java (20)

Aicas, Inc.
Aicas, Inc.Aicas, Inc.
Aicas, Inc.
 
aicas, inc.
aicas, inc.aicas, inc.
aicas, inc.
 
All about PVS-Studio
All about PVS-StudioAll about PVS-Studio
All about PVS-Studio
 
PVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codePVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ code
 
Firmware Co-Design & Development for IP Cores in C++/SystemC using Verilator
Firmware Co-Design & Development for IP Cores in C++/SystemC using VerilatorFirmware Co-Design & Development for IP Cores in C++/SystemC using Verilator
Firmware Co-Design & Development for IP Cores in C++/SystemC using Verilator
 
Production Debugging at Code Camp Philly
Production Debugging at Code Camp PhillyProduction Debugging at Code Camp Philly
Production Debugging at Code Camp Philly
 
From V8 to Modern Compilers
From V8 to Modern CompilersFrom V8 to Modern Compilers
From V8 to Modern Compilers
 
Developer-Friendly CI / CD for Kubernetes
Developer-Friendly CI / CD for KubernetesDeveloper-Friendly CI / CD for Kubernetes
Developer-Friendly CI / CD for Kubernetes
 
Waiting for a cyber range exercise is not enough
Waiting for a cyber range exercise is not enoughWaiting for a cyber range exercise is not enough
Waiting for a cyber range exercise is not enough
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programming
 
How I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScriptHow I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScript
 
Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8
 
Profiling distributed Java applications
Profiling distributed Java applicationsProfiling distributed Java applications
Profiling distributed Java applications
 
Static analysis as means of improving code quality
Static analysis as means of improving code quality Static analysis as means of improving code quality
Static analysis as means of improving code quality
 
C# 4.0 - Whats New
C# 4.0 - Whats NewC# 4.0 - Whats New
C# 4.0 - Whats New
 
Letter to a Junior Developer: The Engineering Side of Programming
Letter to a Junior Developer: The Engineering Side of ProgrammingLetter to a Junior Developer: The Engineering Side of Programming
Letter to a Junior Developer: The Engineering Side of Programming
 
Continuous Delivery for IT Operations Teams
Continuous Delivery for IT Operations TeamsContinuous Delivery for IT Operations Teams
Continuous Delivery for IT Operations Teams
 
OpenCV (Open source computer vision)
OpenCV (Open source computer vision)OpenCV (Open source computer vision)
OpenCV (Open source computer vision)
 
Be armed to the teeth to maintain a high quality iOS code
Be armed to the teeth to maintain a high quality iOS codeBe armed to the teeth to maintain a high quality iOS code
Be armed to the teeth to maintain a high quality iOS code
 
[RHFSeoul2017]6 Steps to Transform Enterprise Applications
[RHFSeoul2017]6 Steps to Transform Enterprise Applications[RHFSeoul2017]6 Steps to Transform Enterprise Applications
[RHFSeoul2017]6 Steps to Transform Enterprise Applications
 

More from Andrey Karpov

60 антипаттернов для С++ программиста
60 антипаттернов для С++ программиста60 антипаттернов для С++ программиста
60 антипаттернов для С++ программистаAndrey Karpov
 
60 terrible tips for a C++ developer
60 terrible tips for a C++ developer60 terrible tips for a C++ developer
60 terrible tips for a C++ developerAndrey Karpov
 
Ошибки, которые сложно заметить на code review, но которые находятся статичес...
Ошибки, которые сложно заметить на code review, но которые находятся статичес...Ошибки, которые сложно заметить на code review, но которые находятся статичес...
Ошибки, которые сложно заметить на code review, но которые находятся статичес...Andrey Karpov
 
PVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesPVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesAndrey Karpov
 
PVS-Studio in 2021 - Feature Overview
PVS-Studio in 2021 - Feature OverviewPVS-Studio in 2021 - Feature Overview
PVS-Studio in 2021 - Feature OverviewAndrey Karpov
 
PVS-Studio в 2021 - Примеры ошибок
PVS-Studio в 2021 - Примеры ошибокPVS-Studio в 2021 - Примеры ошибок
PVS-Studio в 2021 - Примеры ошибокAndrey Karpov
 
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...Andrey Karpov
 
Best Bugs from Games: Fellow Programmers' Mistakes
Best Bugs from Games: Fellow Programmers' MistakesBest Bugs from Games: Fellow Programmers' Mistakes
Best Bugs from Games: Fellow Programmers' MistakesAndrey Karpov
 
Does static analysis need machine learning?
Does static analysis need machine learning?Does static analysis need machine learning?
Does static analysis need machine learning?Andrey Karpov
 
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)Andrey Karpov
 
Game Engine Code Quality: Is Everything Really That Bad?
Game Engine Code Quality: Is Everything Really That Bad?Game Engine Code Quality: Is Everything Really That Bad?
Game Engine Code Quality: Is Everything Really That Bad?Andrey Karpov
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerAndrey Karpov
 
The Use of Static Code Analysis When Teaching or Developing Open-Source Software
The Use of Static Code Analysis When Teaching or Developing Open-Source SoftwareThe Use of Static Code Analysis When Teaching or Developing Open-Source Software
The Use of Static Code Analysis When Teaching or Developing Open-Source SoftwareAndrey Karpov
 
Static Code Analysis for Projects, Built on Unreal Engine
Static Code Analysis for Projects, Built on Unreal EngineStatic Code Analysis for Projects, Built on Unreal Engine
Static Code Analysis for Projects, Built on Unreal EngineAndrey Karpov
 
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded SystemsSafety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded SystemsAndrey Karpov
 
The Great and Mighty C++
The Great and Mighty C++The Great and Mighty C++
The Great and Mighty C++Andrey Karpov
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?Andrey Karpov
 
Zero, one, two, Freddy's coming for you
Zero, one, two, Freddy's coming for youZero, one, two, Freddy's coming for you
Zero, one, two, Freddy's coming for youAndrey Karpov
 
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOpsPVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOpsAndrey Karpov
 

More from Andrey Karpov (20)

60 антипаттернов для С++ программиста
60 антипаттернов для С++ программиста60 антипаттернов для С++ программиста
60 антипаттернов для С++ программиста
 
60 terrible tips for a C++ developer
60 terrible tips for a C++ developer60 terrible tips for a C++ developer
60 terrible tips for a C++ developer
 
Ошибки, которые сложно заметить на code review, но которые находятся статичес...
Ошибки, которые сложно заметить на code review, но которые находятся статичес...Ошибки, которые сложно заметить на code review, но которые находятся статичес...
Ошибки, которые сложно заметить на code review, но которые находятся статичес...
 
PVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesPVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error Examples
 
PVS-Studio in 2021 - Feature Overview
PVS-Studio in 2021 - Feature OverviewPVS-Studio in 2021 - Feature Overview
PVS-Studio in 2021 - Feature Overview
 
PVS-Studio в 2021 - Примеры ошибок
PVS-Studio в 2021 - Примеры ошибокPVS-Studio в 2021 - Примеры ошибок
PVS-Studio в 2021 - Примеры ошибок
 
PVS-Studio в 2021
PVS-Studio в 2021PVS-Studio в 2021
PVS-Studio в 2021
 
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
 
Best Bugs from Games: Fellow Programmers' Mistakes
Best Bugs from Games: Fellow Programmers' MistakesBest Bugs from Games: Fellow Programmers' Mistakes
Best Bugs from Games: Fellow Programmers' Mistakes
 
Does static analysis need machine learning?
Does static analysis need machine learning?Does static analysis need machine learning?
Does static analysis need machine learning?
 
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
 
Game Engine Code Quality: Is Everything Really That Bad?
Game Engine Code Quality: Is Everything Really That Bad?Game Engine Code Quality: Is Everything Really That Bad?
Game Engine Code Quality: Is Everything Really That Bad?
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
 
The Use of Static Code Analysis When Teaching or Developing Open-Source Software
The Use of Static Code Analysis When Teaching or Developing Open-Source SoftwareThe Use of Static Code Analysis When Teaching or Developing Open-Source Software
The Use of Static Code Analysis When Teaching or Developing Open-Source Software
 
Static Code Analysis for Projects, Built on Unreal Engine
Static Code Analysis for Projects, Built on Unreal EngineStatic Code Analysis for Projects, Built on Unreal Engine
Static Code Analysis for Projects, Built on Unreal Engine
 
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded SystemsSafety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
 
The Great and Mighty C++
The Great and Mighty C++The Great and Mighty C++
The Great and Mighty C++
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?
 
Zero, one, two, Freddy's coming for you
Zero, one, two, Freddy's coming for youZero, one, two, Freddy's coming for you
Zero, one, two, Freddy's coming for you
 
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOpsPVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
 

Recently uploaded

The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 

Recently uploaded (20)

The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 

Typical errors in code on the example of C++, C#, and Java

  • 1. Typical errors in code on the example of C++, C#, and Java Information Technology Video Developer Network Информационный видеосервис для разработчиков программного обеспечения http://itvdn.com
  • 2. Георгий Грибков About the speaker Information Technology Video Developer Network http://itvdn.com ITVDN C++ developer of the PVS-Studio static code analyzer • Develops the analyzer core, new diagnostics, supports users. • Introduced PVS-Studio in the godbolt.org online compiler. • Wrote articles for the Habr website and gave talks at IT conferences, related to searching for bugs in code. Typical errors in code on the example of C++, C#, and Java
  • 3. Agenda Information Technology Video Developer Network http://itvdn.com ITVDN 1. Objectives of this webinar 2. How we detected error patterns 3. Patterns themselves and how to avoid them: 3.1 Copy-paste and last line effect 3.2 if (A) {...} else if (A) 3.3 Errors in checks 3.4 Array index out of bounds 3.5 Operator precedence 3.6 Typos that are hard to spot 4. How to use static analysis properly 5. Conclusion 6. Q&A Заключение Typical errors in code on the example of C++, C#, and Java
  • 4. Information Technology Video Developer Network http://itvdn.com ITVDN More than 50 video courses for C# developers at ITVDN C# Basics Author: Alexander Shevchuk Duration: 16 h 3 mins 9 lessons C# Basic (OOP) Author: Alexander Shevchuk Duration: 31 h 26 mins 18 lessons C# for professionals Author: Oleg Kulygin Duration: 19 h 38 mins 17 lessons C# Generics Author: Nikolay Melnichuk Duration: 4 h 49 mins 7 lessons Unit testing in C# Author: Dmitry Okhrimenko Duration: 3 h 48 mins 3 lessons .NET Apps Refactoring Author: David Boyarov Duration: 6 h 41 mins, 5 lessons
  • 5. Information Technology Video Developer Network http://itvdn.com ITVDN More than 26 video courses for Java developers at ITVDN Java Starter Author: Evgeny Tikhonov Duration: 9 h 46 mins 9 lessons Java Essential Author: Evgeny Tikhonov Duration: 11 h 10 mins 10 lessons Java Professional Author : Evgeny Tikhonov Duration: 20 h 18 mins 15 lessons SOLID principles in Java Author: Andrey Fok Duration: 2 h 45 mins 5 lessons Unit testing in Java with JUnit Author: Mikhail Skafenko Duration: 2 h 33 mins 7 lessons Java EE Basics Author: Andrey Bondarenko Duration: 18 h 50 mins 12 lessons
  • 6. Information Technology Video Developer Network http://itvdn.com ITVDN Video courses for C++ developers at ITVDN C++ Starter Author: Vladimir Vinogradov Duration: 8 h 13 mins 13 lessons QT Framework Author: Ruslan Larionenko Duration: 6 h 27 mins 10 lessons C++ Essential Author: Kirill Chernega Duration: 4 h 38 mins 8 lessons C++Advanced Author: Kirill Chernega Duration: 8 h 17 mins 11 lessons Complete practical tasks in C++ Author: Naumenko Alexander Duration: 4 h 39 mins, 7 lessons STL - Standard Template Library Author: Pavlenko Alexander Duration: 7 h 5 mins, 12 lessons
  • 7. Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 8. Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 9. Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 10. Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 11. Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 12. Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 13. Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 14. Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 15. Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 16. Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 17. Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 18. Information Technology Video Developer Network http://itvdn.com ITVDN * Typical errors in code on the example of C++, C#, and Java
  • 19. Information Technology Video Developer Network http://itvdn.com ITVDN BUGS ARE EVERYWHERE! Typical errors in code on the example of C++, C#, and Java
  • 20. How to avoid errors Information Technology Video Developer Network http://itvdn.com ITVDN • Warn developers of typical problems • Use tools to automatically search for errors Typical errors in code on the example of C++, C#, and Java
  • 21. Objectives of this webinar Information Technology Video Developer Network http://itvdn.com ITVDN • Demonstrate typical error patterns in code • Show how to use static analysis properly Typical errors in code on the example of C++, C#, and Java
  • 22. 2. How we detected error patterns Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 23. What is static analysis Information Technology Video Developer Network http://itvdn.com ITVDN Static analysis is automated code review. Typical errors in code on the example of C++, C#, and Java
  • 24. What is static analysis Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 25. Examples of static analyzers Information Technology Video Developer Network http://itvdn.com ITVDN • PVS-Studio • Cppcheck • Infer • IntelliJ IDEA • Clang Static Analyzer • FindBugs • ... Long list of static analyzers: Typical errors in code on the example of C++, C#, and Java
  • 26. How we detected error patterns Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java Found errors 380 13747 Checked projects Detected errors
  • 27. Check out the base of errors we found: Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 28. 3. Patterns themselves and how to avoid them Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 29. Pattern № 1: Copy-paste and last line effect Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 30. Elasticsearch (Java) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 31. Elasticsearch (Java) Information Technology Video Developer Network http://itvdn.com ITVDN PVS-Studio warning: V6039 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains method return. This means that the second 'if' statement is senseless. Typical errors in code on the example of C++, C#, and Java
  • 32. Information Technology Video Developer Network http://itvdn.com ITVDN Clang (C++) Typical errors in code on the example of C++, C#, and Java
  • 33. Information Technology Video Developer Network http://itvdn.com ITVDN Clang (C++) PVS-Studio warning: V501 There are identical sub-expressions SM.getExpansionColumnNumber(ContainerREnd)' to the left and to the right of the '>=' operator. Typical errors in code on the example of C++, C#, and Java
  • 34. Information Technology Video Developer Network http://itvdn.com ITVDN Clang (C++) PVS-Studio warning: V501 There are identical sub-expressions SM.getExpansionColumnNumber(ContainerREnd)' to the left and to the right of the '>=' operator. Typical errors in code on the example of C++, C#, and Java
  • 35. Xenko Game Engine (C#) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 36. Xenko Game Engine (C#) Information Technology Video Developer Network http://itvdn.com ITVDN PVS-Studio warning: V3001 There are identical sub-expressions 'box.Maximum.X - box.Minimum.X > sphere.Radius' to the left and to the right of the '&&' operator. Typical errors in code on the example of C++, C#, and Java
  • 37. Pattern № 1: Copy-paste and last line effect Information Technology Video Developer Network http://itvdn.com ITVDN • We selected 84 examples of erroneous code written with copy-paste • 43 of them had an error in the last line! • It is more than 50%! Typical errors in code on the example of C++, C#, and Java
  • 38. Information Technology Video Developer Network http://itvdn.com ITVDN • Stop copy-pasting • Copy-pasting in programming is pure evil! • If you dare to – be extremely attentive How to avoid Typical errors in code on the example of C++, C#, and Java
  • 39. Pattern № 2. if (A) {...} else if (A) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 40. Elasticsearch (Java) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 41. Elasticsearch (Java) Information Technology Video Developer Network http://itvdn.com ITVDN PVS-Studio warning: V6003 The use of 'if (A) {....} else if (A) {....}' pattern was detected. There is a probability of logical error presence. Typical errors in code on the example of C++, C#, and Java
  • 42. Chromium (C++) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 43. Chromium (C++) Information Technology Video Developer Network http://itvdn.com ITVDN PVS-Studio warning: V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 61, 63. Typical errors in code on the example of C++, C#, and Java
  • 44. CryEngine V (C++) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 45. CryEngine V (C++) Information Technology Video Developer Network http://itvdn.com ITVDN PVS-Studio warning: V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 266, 268. Typical errors in code on the example of C++, C#, and Java
  • 46. CryEngine V (C++) Information Technology Video Developer Network http://itvdn.com ITVDN PVS-Studio warning: V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 266, 268. Typical errors in code on the example of C++, C#, and Java
  • 47. MonoDevelop (C#) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 48. MonoDevelop (C#) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 49. MonoDevelop (C#) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 50. MonoDevelop (C#) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 51. MonoDevelop (C#) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 52. MonoDevelop (C#) Information Technology Video Developer Network http://itvdn.com ITVDN PVS-Studio warning: V3021 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains method return. This means that the second 'if' statement is senseless. Typical errors in code on the example of C++, C#, and Java
  • 53. Information Technology Video Developer Network http://itvdn.com ITVDN • Try to do best not to copy-paste • If you’re still going to copy-paste, copy non-compiled constructions. • Example: if (value == _) return _; How to avoid? Typical errors in code on the example of C++, C#, and Java
  • 54. Pattern № 3. Errors in checks Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 55. Unity (C#) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 56. Unity (C#) Information Technology Video Developer Network http://itvdn.com ITVDN PVS-Studio warning: V3063 A part of conditional expression is always true if it is evaluated: pageSize <= 1000. Typical errors in code on the example of C++, C#, and Java
  • 57. Bullet - the engine of Red Dead Redemption (C++) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 58. Bullet - the engine of Red Dead Redemption (C++) Information Technology Video Developer Network http://itvdn.com ITVDN PVS-Studio warning: V709 Suspicious comparison found: 'f0 == f1 == m_fractureBodies.size()’. Remember that 'a == b == c’ is not equal to 'a == b && b == c'. Typical errors in code on the example of C++, C#, and Java
  • 59. Apache Hive (Java) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 60. Apache Hive (Java) Information Technology Video Developer Network http://itvdn.com ITVDN PVS-Studio warning: V6030 The method located to the right of the '|' operator will be called regardless of the value of the left operand. Perhaps, it is better to use '||'. Typical errors in code on the example of C++, C#, and Java
  • 61. Chromium (C++) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 62. Chromium (C++) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 63. Chromium (C++) Information Technology Video Developer Network http://itvdn.com ITVDN PVS-Studio warnings:  V547 Expression 'time.month <= kDaysInMonth[time.month] + 1' is always true.  V547 Expression 'time.month <= kDaysInMonth[time.month]’ is always true. Typical errors in code on the example of C++, C#, and Java
  • 64. Information Technology Video Developer Network http://itvdn.com ITVDN • «Pay attention!» won’t work every time  • Try backup tools How to avoid Typical errors in code on the example of C++, C#, and Java
  • 65. Pattern № 4. Array index out of bounds Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 66. Stickies (C++) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 67. Stickies (C++) Information Technology Video Developer Network http://itvdn.com ITVDN PVS-Studio warning: V557 Array overrun is possible. The '64' index is pointing beyond array bound. stickies stickies.cpp Typical errors in code on the example of C++, C#, and Java
  • 68. Elasticsearch (Java) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 69. Elasticsearch (Java) Information Technology Video Developer Network http://itvdn.com ITVDN PVS-Studio warning: V6025 Possibly index '(int) x' is out of bounds. Typical errors in code on the example of C++, C#, and Java
  • 70. Elasticsearch (Java) Information Technology Video Developer Network http://itvdn.com ITVDN PVS-Studio warning: V6025 Possibly index '(int) x' is out of bounds. Typical errors in code on the example of C++, C#, and Java
  • 71. IPP Samples (C++) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 72. IPP Samples (C++) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 73. IPP Samples (C++) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 74. IPP Samples (C++) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 75. IPP Samples (C++) Information Technology Video Developer Network http://itvdn.com ITVDN PVS-Studio warning: V557 Array overrun is possible. The '30' index is pointing beyond array bound. Typical errors in code on the example of C++, C#, and Java
  • 76. FastReport (C#) Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 77. FastReport (C#) Information Technology Video Developer Network http://itvdn.com ITVDN PVS-Studio warning: V3106 Possible negative index value. The value of 'idx' index could reach -1. Typical errors in code on the example of C++, C#, and Java
  • 78. Information Technology Video Developer Network http://itvdn.com ITVDN • Be careful when you add '0’ to the end of the string • Do you get an external index? Make sure you check it! • Don’t mix up '>' ('<‘) and '>=' ('<=‘) when comparing the index with the array size How to avoid Typical errors in code on the example of C++, C#, and Java
  • 79. 4. How to use static analysis properly Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 80. When you should perform static analysis Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 81. When you should perform static analysis Information Technology Video Developer Network http://itvdn.com ITVDN Static analysis Typical errors in code on the example of C++, C#, and Java
  • 82. How to make the most of static analysis Information Technology Video Developer Network http://itvdn.com ITVDN • Apply static analysis at early stages • Analyze regularly Typical errors in code on the example of C++, C#, and Java
  • 83. Proprietary development Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 84. Proprietary development Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 85. Proprietary development Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 86. Proprietary development Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 87. Proprietary development Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 88. Corporate development Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 89. Corporate development Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 90. Corporate development Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 91. Corporate development Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 92. Corporate development Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 93. Corporate development Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 94. Corporate development Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 95. Open-source development Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 96. Open-source development Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 97. Open-source development Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 98. Open-source development Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 99. More about analysis of commits and pull-requests Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 100. 5. Conclusion Information Technology Video Developer Network http://itvdn.com ITVDN Typical errors in code on the example of C++, C#, and Java
  • 101. Typical error patterns in code Information Technology Video Developer Network http://itvdn.com ITVDN • Copy-paste and last line effect • if (A) {...} else if (A) • Errors in checks • Array index out of bounds • … (the list gradually expands) Typical errors in code on the example of C++, C#, and Java
  • 102. How to avoid typical errors Information Technology Video Developer Network http://itvdn.com ITVDN • Stop copy-pasting! • Seriously, stop copy-pasting! • Pay attention to checks, even small and short ones. • Carefully check array indexes. • Regularly use static analysis. Typical errors in code on the example of C++, C#, and Java
  • 103. Free PVS-Studio license for students Information Technology Video Developer Network http://itvdn.com ITVDN https://bit.ly/pvs-student Typical errors in code on the example of C++, C#, and Java
  • 104. Information Technology Video Developer Network http://itvdn.com ITVDN Q&A Typical errors in code on the example of C++, C#, and Java
  • 105. Information Technology Video Developer Network http://itvdn.com ITVDN Watch our video lessons on C++ At ITVDN you’ll find a collection of video courses and webinars for C++ developers. Go to ITVDN.com and watch our video lessons right now!
  • 106. IT VIDEO DEVELOPERS NETWORK Information Technology Video Developer Network http://itvdn.com ITVDN