I have found two very interesting questions and answers on Stack Overflow this week that made me learn something new:

  1. How does C++ select the delete operator in case of replacement in subclass?; the answer: the compiler emits two destructors in the vtable: a regular one, and a deleting destructor that also automatically calls its operator delete after. Caveats apply: see the answer in the SO thread.

  2. Why don’t compilers merge redundant std::atomic writes? (and also Can the C++ compiler coalesce adjacent mutex locks?); the answer: the standard would allow them to, but it would violate the principle of least surprise and make some code not work as expected (such as updating progress bars), so they currently just choose not to. There are proposals in place to add something to the standard that would indicate to the compiler that it’s safe to make such optimizations. There are good examples and details in the SO answers.