In my matrix class, I allocate aligned memory as such:
/*** main.cpp ***/
#include "matrix.hpp"
int main()
{
{
Matrix(15, 17);
}
return 0;
}
/** matrix.hpp **/
class Matrix
{
private:
std::size_t width_, height_;
double* data_;
public:
Matrix(std::size_t width, std::size_t height);
~Matrix();
};
/** matrix.cpp **/
Matrix::Matrix(std::size_t width, std::size_t height)
: width_(width)
, height_(height)
{
data_ = new(std::align_val_t{64}) double[width_ * height_];
}
How do I properly delete it?
I tried both
Matrix::~Matrix()
{
delete[] data_;
}
and
Matrix::~Matrix()
{
delete[](std::align_val_t{64}, data_);
}
But I get the errors:
SIGTRAP (Trace/breakpoint trap)
ntdll!RtlIsNonEmptyDirectoryReparsePointAllowed 0x00007ffe5dc390e3
ntdll!RtlpNtMakeTemporaryKey 0x00007ffe5dc41512
ntdll!RtlpNtMakeTemporaryKey 0x00007ffe5dc4181a
ntdll!RtlpNtMakeTemporaryKey 0x00007ffe5dc4a7d9
ntdll!RtlGetCurrentServiceSessionId 0x00007ffe5db8081d
ntdll!RtlFreeHeap 0x00007ffe5db7fba1
msvcrt!free 0x00007ffe5bc09cfc
Matrix::~Matrix matrix.cpp:15
main main.cpp:16
__tmainCRTStartup 0x00000000004013c1
mainCRTStartup 0x00000000004014f6
where line 15 refers to the line containing either delete[].
I'm using MSys2's g++ 10.1 on Windows10.
edit: If I compile this under WSL with g++ 10.1 it works just fine. So this is probably caused by the Windows port.