Aliasing: Risks, Opportunities and Techniques
summary
Aliasing in C++ causes both correctness failures and big slowdowns: overlapping arguments break a naive in-place min/max and a concat example, a simple byte-by-byte loop copy clobbers data while memmove and some library calls survive but std::copy is undefined for overlaps, compilers (GCC/Clang/Intel) disagree on behaviors, and a microbenchmark shows taking a coefficient by const& incurs a 32× slowdown versus by-value. Remedies shown include strong typedefs, copying defensively or runtime disjoint checks, and using memmove or documented-safe STL patterns.
AI-written summary · about
chapters (11)
- 0:00Introduction to aliasing
- 1:48Understanding aliasing
- 5:28Examples of aliasing pitfalls
- 10:40Buffer and STL aliasing issues
- 14:00STL algorithms and aliasing
- 18:31Performance impact of aliasing
- 24:13Compiler, language, and standards
- 30:01Strict aliasing and types
- 36:11Best practices and strategies
- 42:08Future proposals
- 46:26Unions, variants, and summary
related talks
37mDealing with aliasing using contracts
01h 19mThis is C++: Uncompromised Performance, Undefined Behavior, & Move Semantics
01h 27mDangerous Optimizations! in C++ - Part Deux
01h 23mThis is C++ - How to Use the C++ Superpower to Write Better C++ Code
01h 05mDon’t Get Overloaded by C++ Overload Sets
15mC++ WAT
01h 30mDangerous Optimizations in C and C++ Programming Languages
51mC++ Features You Might Not Know
