Alignment problem with custom class and stl container with Intel Compiler

Summary

We use an Eigen Matrix as a member in a custom class and put this class into an STL container (vector). When compiling this with the Intel compiler (using C++17) and the unaligned assert is triggered when executing. We tested different Intel compiler from 2019 to 2021 and different compiler flags including -g -O0

The Problem can be fixed with a custom allocator as shown in the minimal example (commented out). To my understanding this should not be necessary when using C++17. The code also works with other compilers like gcc, clang and icx (Intel OneApi)

Environment

  • Operating System : Ubuntu 20.04
  • Architecture : x64
  • Eigen Version : 3.4
  • Compiler Version : icpc (ICC) 2021.4.0 20210910
  • Compile Flags : -std=c++17 -xHost
  • Vector Extension : AVX

Minimal Example

#include <Eigen/Dense>
#include <map>
#include <vector>

template < typename T, uint64_t M, uint64_t N >
class OurMatrix
{

 public:
   Eigen::Matrix< T, M, N > matrix_;
};

int main(){
 std::vector< OurMatrix< double, 4, 4 > > localElementMatrices2D_;
 //FIX: std::vector< OurMatrix< double, 4, 4 > ,Eigen::aligned_allocator< OurMatrix< double, 4, 4  > > > localElementMatrices2D_;

 localElementMatrices2D_.resize(1);
 localElementMatrices2D_.resize(2);
}

Steps to reproduce

  1. icpc -std=c++17 -xHost MinimalExample.cpp
  2. ./a.out

What is the current bug behavior?

The unaligned assertion is triggered

What is the expected correct behavior?

Since C++17 is used a custom allocator should not be necessary

Relevant logs

... /DenseStorage.h:147: Eigen::internal::plain_array<T, Size, MatrixOrArrayOptions, 64>::plain_array() [with T = double; int Size = 16; int MatrixOrArrayOptions = 0]: Assertion `(internal::UIntPtr(eigen_unaligned_array_assert_workaround_gcc47(array)) & (63)) == 0 && "this assertion is explained here: " "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" " **** READ THIS WEB PAGE !!! ****"' failed.
fish: './IntelEigenAligend' terminated by signal SIGABRT (Abort)