Aliasing in C++ - Risks, Opportunities and Techniques
summary
Examples show real failures: a naive loop-copy breaks overlapping buffers, std::memmove survives but strcpy/copy_n are undefined in those cases, and compilers differ (Clang vs ICC). Passing a coefficient by value lets the compiler hoist and vectorize and yields 32× faster results on QuickBench. Practical fixes include memmove/move algorithms, strong typedefs, execution policies, and optional pass-by-value policy dispatch. A union-based layout trick appears to work on some compilers but is effectively UB and not portable.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:10What is aliasing?
- 9:26Aliased buffers
- 13:17STL algorithms aliasing
- 22:24Performance implications
- 23:03Summary of aliasing issues
- 24:21Aliasing in C and languages
- 34:17C++ strict aliasing rules
- 34:55Mitigation strategies
- 37:29Future of aliasing in C++
- 50:19Conclusion
related talks
36mInterfaces Matter
58mC++ Performance and Optimisation
01h 00m“Want fast C++? Know your hardware!"
01h 00mMoving Faster: Everyday efficiency in modern C++
01h 01mFaster, Easier, Simpler Vectors
01h 05mFast and small C++ - When efficiency matters
58mOptimization Tips - Mo' Hustle Mo' Problems
49mMaking Allocators Work, Part I
