The most dangerous function in the C/C++ world

Most errors that I see in the projects are related to the usage of this particular memset() function.

The most dangerous function in the C/C++ world

by Andrey Karpov

From the article:

Now I have another interesting observation. Using one or another function, the programmers can make mistakes. That is clear, you may say. But the probability of the error may also depend on the function. In other words, some functions provoke errors, and some don't. And now I am ready to name the function which causes most of the troubles and using which you have the biggest chance of an epic fail.

Add a Comment

Comments are closed.

Comments (2)

0 0

jsj said on Dec 3, 2015 03:57 AM:

Nice article. When passing a literal value as the second parameter to memset I always use a hex literal (i.e. 0x00), to reinforce the point that this isn't an int it's a single byte. A small thing but every little helps.
0 0

jbruni said on Dec 4, 2015 04:52 PM:

To me, it looks more like the abuse of `sizeof` is the culprit, more than `memset()`.