Pour obtenir une clé
d'essai remplissez le formulaire ci-dessous
Demandez des tariffs
Nouvelle licence
Renouvellement de licence
--Sélectionnez la devise--
* En cliquant sur ce bouton, vous acceptez notre politique de confidentialité

Free PVS-Studio license for Microsoft MVP specialists
To get the licence for your open-source project, please fill out this form
** En cliquant sur ce bouton, vous acceptez notre politique de confidentialité.

I am interested to try it on the platforms:
** En cliquant sur ce bouton, vous acceptez notre politique de confidentialité.

Votre message a été envoyé.

Nous vous répondrons à

Si vous n'avez toujours pas reçu de réponse, vérifiez votre dossier
Spam/Junk et cliquez sur le bouton "Not Spam".
De cette façon, vous ne manquerez la réponse de notre équipe.

64-bit Errors Are Here at Last

64-bit Errors Are Here at Last

02 Jui 2014

As a person not indifferent to 64-bit errors, I decided to write a small comment to the article "Buggy Security Guidance from Apple".


Many applications have been already ported to 64 bits and seem to be working well. However, 64-bit errors still inhabit many of them, lying in wait. Only a very attentive programmer can notice them. Or the PVS-Studio code analyzer.

I have recently stumbled across an interesting article titled "Buggy Security Guidance from Apple".

Before going on to read my comment, please read the article first. What I found of interest there is the fact that after having accomplished huge work and successfully implemented checks for overflows one might easily make a mistake in some very simple thing - in particular, multiply two 'int' variables and write the result into a 'size_t' variable.

I mean the following line:

size_t bytes = n * m;

It is recommended to be replaced with this one:

size_t bytes = (size_t)n * (size_t)m;

This is a very common type of 64-bit errors, awfully difficult to notice and detect.

The world seems to start facing at last what I already described several years ago in my articles and manual on 64-bit software development. So I do recommend you to read those materials:

But what is most important, it's not enough to be simply aware of these errors. True, you will make sure your new code is written correctly. But what about the old code? How many defects of that kind does it have and how to catch them?

I'll give you a hint. You need to use the PVS-Studio analyzer - or rather, its set of 64-bit diagnostics.

To get the proof that the error with an overflow is a common one, take a look at the warning the analyzer generates on the line "size_t bytes = n * m;".

The diagnostic message: V101 Implicit assignment type conversion to memsize type.

Notice its number - V101. It was the very first 64-bit diagnostic rule that we had implemented. The dangers programmers are talking about nowadays were obvious to us long ago. So don't hesitate: PVS-Studio is a perfect tool for catching 64-bit bugs.

Note. Be prepared for numbers of false positives generated by 64-bit diagnostics. They can't be avoided. The analyzer does not know if the program counts the number of days in a month or computes the size of some big file. It happens quite frequently that PVS-Studio can't understand what values are stored in variables and if an overflow will occur. Unfortunately, there is no better alternative to be found around anyway. PVS-Studio is the leader in the area of 64-bit error detection. And it also offers lots of false positive suppression mechanisms.

Comments (0)

Next comments
Unicorn with delicious cookie
Nous utilisons des cookies pour améliorer votre expérience de navigation. En savoir plus