The production bug that made me care about undefined behavior

40 points by dryya


muvlon

in some conditions, Response response; is perfectly fine. In some other cases, this is undefined behavior.

Yup, classic C++. Initialization is a huge complex mess, but somehow they still don't seem to have developed a culture of defensively initializing everything explicitly always and play these silly shorthand games instead.

At least in this case, there is maybe an out. There is a serious proposal to change the language s.t. it always zero-initializes local variables: https://isocpp.org/files/papers/P2723R0.html

And before you scream about performance, go read their report, please. They address this very well.