📜 ⬆️ ⬇️

Let's play a game

PVS-Studio. Let's play a game.
The authors of the PVS-Studio analyzer suggest you to check your attentiveness.

Code analyzers work tirelessly and are able to find a lot of errors that are difficult to notice. We selected some code fragments in which we identified errors using PVS-Studio. All fragments are taken from well-known Open-Source projects.

We suggest you to compete with analyzers in perspicacity and try to find errors yourself. You will be offered 15 randomly selected assignments. For the correct answer there is one point, if it is given within 1 minute. Code snippets are short, and 1 minute is an honest limitation.

')
Consider a couple of examples with errors and explain how to specify the correct answer.

The first example. Here is the following code:

Example 1

Here the error is highlighted in red. In solving this problem, of course, will not.

The programmer accidentally sealed and instead of index 2 he wrote 3. When the mouse cursor moves over the code, various words and numbers will be highlighted. You must hover over the number 3 and click the left mouse button.

This will be the correct answer.

The second example. It is not always possible to unequivocally indicate where the error is:

Example 2

The buffer size must be compared with the number 48. Randomly in the code there was an extra sizeof () operator. As a result, the buffer size is compared with the size of the int type.

In my opinion, the error is the “sizeof” operator, and it is precisely it that must be indicated with the mouse. However, without having before your eyes the whole text of the program, it is possible to judge so. The 'sizeof' operator was supposed to calculate the size of a buffer, but he was accidentally slipped a macro. An error is the use of "SSL3_MASTER_SECRET_LENGTH".

For such cases, the answer will be counted as correct, regardless of whether you select sizeof or SSL3_MASTER_SECRET_LENGTH.

And now we wish you good luck. Start the game .

PS We understand that the tasks are not perfect, it is not always obvious where you need to “poke the mouse”, and the system can be deceived if you wish. Just keep in mind that this section of the site is created for fun, not for the full testing of someone.

Source: https://habr.com/ru/post/237219/


All Articles