Tag Archives: undefined behavior

Understanding Undefined Behavior

One of the harder concepts for people to understand in C++, in my opinion, is “behavior.” In C++, the language has some very specific wording for what the various behaviors are, and I’ve seen a lot of people get them … Continue reading

Posted in C/C++ | Tagged , | Leave a comment

Crashing: Easy to Do When You Don’t Want to, Hard When You Do

The challenge: in C or C++, come up with a way to crash your application, running as little code as possible. It should be a cross-platform solution that works with any compiler, on any system, with any CPU architecture.

Posted in C/C++ | Tagged , | 4 Comments

The Joys of Bit Fields

In C and C++, bit fields are one of the more odd declaration types that you run into rarely. The basic idea behind them is to provide the programmer with a way to define declarations at the bit-level. For instance, … Continue reading

Posted in C/C++ | Tagged , , | 2 Comments

When Should You Use const_cast?

C++ provides an explicit casting mechanism called const_cast, and yet the question pops up: when would I ever use this? You can always assign a non-const value to a const value without requiring a cast operation. So you don’t need … Continue reading

Posted in C/C++ | Tagged , , | 7 Comments