Mateusz Nowak


Mateusz Nowak is a software engineer, mostly focused on low-level stuff: Firmware, drivers, etc., but also on training other people on technical and soft skills topics. Holding Master degrees in Computer Science and Managements. Interested in C++, motivation, and team work organization.



When you hit "Error: memory is not aligned." (2018)

In this talk, I will try to cover the topic of memory alignment in C++. I will discuss why it is sometimes necessary to care about alignment and how the memory is aligned by default. I will go through different methods of ensuring alignment, that apply to pre-C++11, C++11, and C++17, presenting and describing code examples.


  1. What is alignment and why one may need to care about it.
  2. Default rules for alignment.
  3. Pre C++11 and compiler specific attributes and functions (very short overview).
  4. alignas, alignof and std::aligned_storage.
  5. aligned_alloc (and its predecessors) and custom aligned allocators.
  6. std::align_val_t and new with custom alignment.