Understanding GCC warnings--Martin Sebor

In detail.

Understanding GCC warnings

by Martin Sebor

From the article:

Most of us appreciate when our compiler lets us know we made a mistake. Finding coding errors early lets us correct them before they embarrass us in a code review or, worse, turn into bugs that impact our customers. Besides the compulsory errors, many projects enable additional diagnostics by using the -Wall and -Wextra command-line options. For this reason, some projects even turn them into errors via -Werror as their first line of defense. But not every instance of a warning necessarily means the code is buggy. Conversely, the absence of warnings for a piece of code is no guarantee that there are no bugs lurking in it...

A gentle introduction to jump threading optimizations--Aldy Hernandez

Your complier does magic.

A gentle introduction to jump threading optimizations

by Aldy Hernandez

From the article:

As part of the GCC developers‘ on-demand range work for GCC 10, I’ve been playing with improving the backward jump threader so it can thread paths that are range-dependent. This, in turn, had me looking at the jump threader, which is a part of the compiler I’ve been carefully avoiding for years. If, like me, you’re curious about compiler optimizations, but are jump-threading-agnostic, perhaps you’ll be interested in this short introduction...

Thanks for the memory (allocator)--Glennan Carnie

Unifying the types.

Thanks for the memory (allocator)

by Glennan Carnie

From the article:

One of the design goals of Modern C++ is to find new – better, more effective – ways of doing things we could already do in C++.  Some might argue this is one of the more frustrating aspects of Modern C++ – if it works, don’t fix it (alternatively: why use lightbulbs when we have perfectly good candles?!)

This time we’ll look at a new aspect of Modern C++:  the Allocator model for dynamic containers.  This is currently experimental, but has been accepted into C++20.

The Allocator model allows programmers to provide their own memory management strategy in place of their default library implementation.  Although it is not specified by the C++ standard, many implementations use malloc/free.

Understanding this feature is important if you work on a high-integrity, or safety-critical, project where your project standards say ‘no’ to malloc...

C++ Russia 2019: April 19-20, Moscow

C++ Russia 2019 will be held in Moscow, April 19–20, 2019.

Two days, three tracks and dozens of deep technical talks about C++: concurrency, performance, architecture, environment — all you need to make your code perfect.

C++ R​ussia 2019: Moscow, April 19–20, 2019

by Sergey Platonov

From the article:

Keynote by Nicolai Josuttis and Anton Polukhin.

Also at the conerence: Philip Nash, Valentin Ziegler, Ivan Čukić, Viktor Kirilov, Andrey Davydov, Alexander Granin and many others.

C++ Russia is not only talks, but also networking with hundreds of colleagues from Russia and Europe. Due to dedicated discussion zones, all the speakers have after their talks all the questions will be answered.

If you need to solve any practical issue right now — you can find Ask Expert zone and ask speakers to help you.

And in the evening you can participate in BoF-sessions where the most uncommon ideas are born.

One of track will be entirely in English.

 

 

 

CppDepend v2019.1 Released including Misra C++ Standard!

We are happy to inform you that CppDepend v2019.1 has been released and is now available for download! CppDepend allows architects and developers to analyze C and C++ code base, customizing your own coding rules, and facilitate refactoring and migration.

CppDepend v2019.1

by CppDepend

About the release:

includes important updates:

  • Misra C++ standard checks:  CppDepend 2019.1 provides now out of the box 90 MISRA guidelines to facilitate code safety, security, portability, and reliability.
  • Plugins execution optimization: in order to get the CppDepend results quickly, the execution of the plugins are now executed in asynchronous mode. Their results will be loaded as soon as the analysis is done.
  • Clang Tidy customization: The Clang tidy tool checks against many standards and guidelines which makes it very slow, To optimize its execution you can now change its command line arguments to check only what you want as guidelines.
  • (Improvement) Many bug fixes and improvements including SonarQube 7.6 compatibility.

Download and enjoy the new version of CppDepend now by clicking here.

Quick Q: Pointer to class data member “::*”

Quick A: a pointer that lets you access the value of the member of an instance.

Recently on SO:

Pointer to class data member “::*”

It's a "pointer to member" - the following code illustrates its use:

#include <iostream>
using namespace std;

class Car
{
    public:
    int speed;
};

int main()
{
    int Car::*pSpeed = &Car::speed;

    Car c1;
    c1.speed = 1;       // direct access
    cout << "speed is " << c1.speed << endl;
    c1.*pSpeed = 2;     // access via pointer to member
    cout << "speed is " << c1.speed << endl;
    return 0;
}

As to why you would want to do that, well it gives you another level of indirection that can solve some tricky problems. But to be honest, I've never had to use them in my own code.

Edit: I can't think off-hand of a convincing use for pointers to member data. Pointer to member functions can be used in pluggable architectures, but once again producing an example in a small space defeats me. The following is my best (untested) try - an Apply function that would do some pre &post processing before applying a user-selected member function to an object:

void Apply( SomeClass * c, void (SomeClass::*func)() ) {
    // do hefty pre-call processing
    (c->*func)();  // call user specified function
    // do hefty post-call processing
}

The parentheses around c->*func are necessary because the ->* operator has lower precedence than the function call operator.

C++ Core Guidelines: Mixing C with C++--Rainer Grimm

Mixing C and C++ from the point of view of a C++ engineer.

C++ Core Guidelines: Mixing C with C++

by Rainer Grimm

From the article:

The chapter in the C++ core guidelines is called: C-style programming. Honestly, my first thought was to skip it, but after more thoughts I decided to write about it. My reason is twofold:

  1. This are the typical issues we have when dealing with legacy code.
  2. One reader wanted that I write more about the challenges of legacy code.

Understanding C++ Modules: Part 1: Hello Modules, and Module Units--Colby Pike

Complex, but useful!

Understanding C++ Modules: Part 1: Hello Modules, and Module Units

by Colby Pike

From the article:

My previous posts on modules have received a lot of attention. I’m happy that I’ve been able to kick-start a lot of conversation, but I’ve also seen that a large part of the community is still unclear on what modules actually are.

There is a lot of ground to cover. I can’t do it all in one sitting, and I doubt you’d want to read the entire thing in one go. I’ll be breaking this up, starting at the most high-level aspects and drilling down over time. I intend these posts will clarify and discuss what modules are, what they can do, and what they are intended to do, what they cannot do, and how they are used...

Lambdas: From C++11 to C++20, Part 2--Bartlomiej Filipek

The series continues!

Lambdas: From C++11 to C++20, Part 2

by Bartlomiej Filipek

From the article:

In the first part of the series we looked at lambdas from the perspective of C++03, C++11 and C++14. In that article, I described the motivation behind this powerful C++ feature, basic usage, syntax and improvements in each of the language standards. I also mentioned several corner cases.

Now it’s time to move into C++17 and look a bit into the future (very near future!): C++20...