Runtime error on IBM POWER

Issue #232 resolved created an issue

Howdy -

The HPX/Phylanx project found a bug in blaze/util/Memory.h when allocating a DynamicVector. In the call to allocate_backend() from line 160 of allocate(), posix_memalign() is called with alignment of 4 and size of 4028. However, sizeof(void*) on this platform is 8. The posix_memalign() call fails, because according to the posix_memalign man page, alignment must be a multiple of sizeof(void*).

If I add this line before the posix_memalign() call, the code works:

   alignment = (alignment < sizeof(void*) ? sizeof(void*) : alignment);

I am not sure why this would work on x86_64 platforms, though - it should fail there, too!

With this test program, I get the following output on POWER with the Clang 7 compiler and the same output on x86_64 with g++7:


int main (int argc, char** argv) {
    std::cout << "Size of void* : " << sizeof(void*) << std::endl;
    std::cout << "Size of int : " << sizeof(int) << std::endl;
    std::cout << "Size of std::alignment_of<int>::value : " << std::alignment_of<int>::value << std::endl;
    std::cout << "Size of std::alignment_of<int>() : " << std::alignment_of<int>() << std::endl;


Size of void* : 8
Size of int : 4
Size of std::alignment_of<int>::value : 4
Size of std::alignment_of<int>() : 4

For a longer discussion, see


Comments (4)

  1. Klaus Iglberger


    Thanks for reporting this issue and thanks for providing a fix. I will integrate it as quickly as possible.

    Best regards,


  2. Klaus Iglberger

    Commit 954950b fixes the minimum alignment for calls to the posix_memalign() function. The fix is immediately available via cloning the Blaze repository and will be officially released in Blaze 3.5.

  3. Log in to comment