Why it is important to check what the malloc function returned

Unfortunately, many programmers are careless about checking of pointers, and sometimes they deliberately do not check whether to memory was allocated or not.

Why it is important to check what the malloc function returned

by Andrey Karpov

From the article:

There are 4 reasons at once, each of them is enough to prove that it is so necessary to write a check after you call the malloc function. If someone from your team doesn't write the checks, make him read this article.

  1. Null pointer dereference is undefined behavior
  2. Null pointer dereference is a vulnerability
  3. Where are guarantees that dereferencing of exactly a null pointer will occur?
  4. Where are the guarantees that memset fills the memory in a direct order?

CppDepend v2018.1 Released - CERT/HICPP standard Checks, C++ Core guidelines support and much more.

We are happy to inform you that CppDepend v2018.1 has been released and is now available for download!

More Information about CppDepend v2018.1 new features!

by CoderGears

About the release:

CppDepend v2018.1 allows architects and developers to analyze C and C++ code base. Measure, query and visualize source code and avoid unexpected issues, technical debt and complexity.

Start your 1-month free trial!

About the release

With CppDepend v2018.1 Save time, reduce costs and deliver high-quality code with these important updates:

  • CERT (SEI CERT C++ Coding Standard ) standard checks
  • HICPP (High Integrity C++) standard checks
  • More rules to check your modern C++ codebase(C++11,C++14,C++17): More than 20 modernization detections
  • Clang-tidy tool embedded for more issues detection
  • Analysis of the CMake format specification: CppDepend analyzes now out of the box the CMake Compilation Database Format Specification.
  • C++ Core Guidelines support
  • New rules related to the performance and the readability issues

 

The Most Vexing Parse: How to Spot It and Fix It Quickly--Jonathan Boccara

Did you have that problem?

The Most Vexing Parse: How to Spot It and Fix It Quickly

by Jonathan Boccara

From the article:

Everyone has their little defaults. You know, that little something that they do from time to time and that gets on your nerves, even though they’re otherwise nice people?

For C++, one of these little annoyances is the most vexing parse, well, as its name suggests...

Help the compiler warn you

And make less mistakes.

Help the compiler warn you

by Andrzej Krzemieński

From the article:

Compiler warnings are a very useful tool for detecting bugs in your program. Because you can enable them selectively, and because you can choose to turn them into hard errors on your compiler, you can in fact build a dialect, which is a safer subset of C++...

break and fallthrough--Andrey Karpov

A classic error:

break and fallthrough

by Andrey Karpov

From the article:

We would like to suggest reading the series of articles dedicated to the recommendations on writing code of high quality using the examples of errors found in the Chromium project. This is the second part, which will be devoted to the switch operator and, more precisely, to the problem of a forgotten break operator...

GCC 7.3 released

It continues to improve:

GCC 7.3 released

From the article;

This page is a brief summary of some of the huge number of improvements in GCC 7. For more information, see the Porting to GCC 7 page and the full GCC documentation...

Guidelines for constructor and cast design--Jonathan Müller

Interesting indeed!

Guidelines for constructor and cast design

by Jonathan Müller

From the article:

A while back — but sadly not too many blog posts ago — I wrote about explicit constructors and how to handle assignment. In this blog post, I made the assumption that you most likely want to have explicit single argument constructors.

But when do we actually want implicit single argument constructors?

Let’s consider the broader question: How should I design a cast operation for my user-defined type? And how should I design a constructor?

But first, something different: what is the difference between a cast and a constructor?