I'm going on to tell you about how programmers walk on thin ice without even noticing it. Let's speak on shift operators <<, >>. The working principles of the shift operators are evident and many programmers even don't know that using them according to the C/C++ standard might cause undefined or unspecified behavior.

I would like to begin this article from the fact that now it is 2012. I am saying this, because I often read the code in C++ at my work and for hobby, which was written about 10-20 years ago (and it is actual now), or the code written recently by the people who learned to program in C++ 20 years ago. And after that I got feeling that there was not any progress over the years, as well nothing was changed and developed, and the mammoths still roam on the Earth.
Introduction
The programming specific was very different 20 years ago. The memory and resources of CPU were measured by the bytes and the cycles, many things had not been invented yet, and we had to deal with that situation. But this is not an excuse today to write a code based on these prerequisites. The world is changing now. I can feel it in the water. I can feel it in the ground. We need to keep up with the progress.
Everything that I am going to write further only applies to the programming in C++ and the mainstream-compilers (gcc, Intel, and Microsoft), unfortunately, I have worked less with other programming languages and compilers, so I will not talk much about them. Also, I will only talk about the application programming for desktop OS (trends may differ in the clusters, microprocessors and system programming).

More than a year has passed since we analyzed Notepad++ with PVS-Studio. We wanted to see how much better the PVS-Studio analyzer has become since then and which of the previous errors have been fixed in Notepad++.
In C language, you may use functions without defining them. Pay attention that I speak about C language, not C++. Of course, this ability is very dangerous. Let us have a look at an interesting example of a 64-bit error related to it.
I decided to find out if there is practical sense in writing ++iterator instead of iterator++ when handling iterators. My interest in this question arouse far not from my love to art but from practical reasons. We have intended for a long time to develop PVS-Studio not only in the direction of error search but in the direction of prompting tips on code optimization. A message telling you that you'd better write ++iterator is quite suitable in the scope of optimization.
But how much relevant is this recommendation nowadays? In ancient times, for instance, it was advised not to repeat calculations. It was a good manner to write:
TMP = A + 10;
X = TMP + B;
Y = TMP + C;
instead of
X = A + 10 + B;
Y = A + 10 + C;
Such subtle manual optimization is meaningless now. The compiler would handle this task as well. It's just unnecessary complication of code.

I create the PVS-Studio analyzer detecting errors in source code of C/C++/C++11 software. So I have to review a large amount of source code of various applications where we detected suspicious code fragments with the help of PVS-Studio. I have collected a lot of examples demonstrating that an error occurred because of copying and modifying a code fragment. Of course, it has been known for a long time that using Copy-Paste in programming is a bad thing. But let's try to investigate this problem closely instead of limiting ourselves to just saying "do not copy the code".
"C++11 feels like a new language." - Bjarne Stroustrup
Recently, Herb Sutter has opened on its website a new page “Elements of Modern C++ Style”, where he describes the advantages of the new standard and how they will affect the code.
C++11 standard introduces many new features. Next, we focus specifically and only on those features that make C++11 really feel like a new language compared to C++98, namely:
• They change the styles and idioms you will use when writing C++ code, often including the way you will design C++ libraries. For example, you will see more smart pointer parameters and return values, and functions that return big objects by value.
• They will be used so pervasively that you will probably see them in most code examples. For example, virtually every five-line modern C++ code example will say “auto” somewhere.
Introduction
C ++ is unmanaged language, because the programs can escape without saving the user’s data and give the error messages, etc. For example, it takes only to get into an uninitialized memory. For example:
void fall()
{
char * s = "short_text";
sprintf(s,"This is very long text");
}
or
void fall()
{
int * pointer = NULL;
*pointer = 13;
}
It would be better if we could "catch" a program crash just like in java we are catching exceptions, as well we could do anything before the program will crash (save the user’s document, display a dialog with the error message, etc.)A task does not have a general solution, as C ++ does not have its own model of exception handling that is work-related with the memory. Nevertheless, we will consider two methods that are using the features of the operating system that caused an exception.
Unlike most assemblers, the result of multiplication has the same number of digits as the multipliers in C / C + +. In order not to lose the accuracy, sometimes it is needed to perform additional operations for the multiplication.
Let us consider the task. The system determines the time since starting the program in the microprocessor’s ticks by calling the function:
unsigned long long getTickCount ();
Length unsigned long long - 64 bits. Converting to the physical units of time in the system, there is a constant:
const unsigned long long TICKS_PER_SECOND = 1999000000ULL;
It is required to determine the function of transferring ticks in a nanoseconds getNsec (unsigned long long ticks) with semantics:
unsigned long long getNsecNaive (unsigned long long ticks) {
static const unsigned long long NSEC_PER_SECOND = 1000000000ULL;
unsigned long long nsec = NSEC_PER_SECOND * ticks / TICKS_PER_SECOND;
return nsec;
}