Skip to content

Error: no arguments to '_mm_malloc' or '_mm_free' that depend on a template parameter #4

Description

@Millani

Hi there,

Using g++ (version 7) in Ubuntu 18.04, I tried to compile a single simple Levenshtein distance calculation with:

#include <algorithm>
#include <string>
#include "levenshtein-sse.hpp"
#include <iostream>

int main() {
    std::cout << levenshteinSSE::levenshtein("baaad", "bad") <<std::endl;
    return 0;
}

But I get the following error:

levenshtein-sse.hpp: In member function ‘T* levenshteinSSE::AlignmentAllocator<T, N>::allocate(levenshteinSSE::AlignmentAllocator<T, N>::size_type)’:
levenshtein-sse.hpp:102:62: error: there are no arguments to ‘_mm_malloc’ that depend on a template parameter, so a declaration of ‘_mm_malloc’ must be available [-fpermissive]
     return reinterpret_cast<pointer>(reinterpret_cast<char*>(_mm_malloc(n * sizeof(value_type) + 8 * N, N)) + 4*N);
                                                              ^~~~~~~~~~
levenshtein-sse.hpp:102:62: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
levenshtein-sse.hpp: In member function ‘void levenshteinSSE::AlignmentAllocator<T, N>::deallocate(levenshteinSSE::AlignmentAllocator<T, N>::pointer, levenshteinSSE::AlignmentAllocator<T, N>::size_type)’:
levenshtein-sse.hpp:106:5: error: there are no arguments to ‘_mm_free’ that depend on a template parameter, so a declaration of ‘_mm_free’ must be available [-fpermissive]
     _mm_free(reinterpret_cast<char*>(p) - 4*N);

Indeed, compiling with -fpermissive bypasses the issue and gets the code compiled and the distance calculation performed. However, in the real application setup I am working with, I cannot leave the -fpermissive flag enabled.

Hence, my question: could you please give me any hint at how to solve that error? If it helps to know, my CPU does have SSE2 and AVX instructions enabled.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions