Tag Archives: gotchas

(Not) detecting bugs

The following code contains a bug. A developer has spent quite some time looking for the source. The intent of this code is to iterate over two vectors simultaneously, from the first up to the one-before-last element. Thus the most … Continue reading

Posted in programming | Tagged , , , , | 1 Comment

The One-Definition Rule

We have been hit by the same bug twice already this year. It ends in a crash, and it took developers days to find it (in each case), even though it is reproducible on each run of unit tests. The … Continue reading

Posted in programming | Tagged , , | 14 Comments

Is constructible?

Today I want to share with you something that really surprised me. Currently, Tomasz Kamiński and Ville Voutilainen are working on fixing a certain issue with std::optional’s converting constructors (which deserves a separate post). At some point, in the solution, … Continue reading

Posted in programming | Tagged , , | 9 Comments

The cost of std::initializer_list

C++ aims to be a language for people working close to metal. It offers abstractions that cost no (or minimum) run-time or memory overhead. If you require zero-overhead abstractions, std::initializer_list may not be a tool for you.

Posted in programming | Tagged , | 18 Comments

Competing constructors

We start with a known C++ gotcha: In this post I want to analyze the source of the problem a bit further, and offer some suggestions on class design.

Posted in programming | Tagged , , , , | 7 Comments

Overload resolution

This post is an introduction to another one that I intend to write in the future. The goal of this one is to go over the concepts of function template specialization, function (template) overloading, argument dependent lookup (ADL) and overload … Continue reading

Posted in programming | Tagged , , , , | 16 Comments

More than you need

The classes you design can do more (in terms of allowed operations) than what you could figure out from just looking at their member function declarations. The C++ Standard defines a number of cases where certain expressions involving your type … Continue reading

Posted in programming | Tagged , , , , , | 14 Comments