How to fix warning: attempt to free a non-heap object

I am compiling a host code using make command. The bellow errors showed up.

The sub code that caused this part of errors:

free(data_point);
    free(host_output);
    free(index_arr);
    free(array_dist);

Errors:

host/src/host.cpp:380:21: warning: attempt to free a non-heap object ‘data_point’ [-Wfree-nonheap-object]
     free(data_point);
                     ^
host/src/host.cpp:381:22: warning: attempt to free a non-heap object ‘host_output’ [-Wfree-nonheap-object]
     free(host_output);
                      ^
host/src/host.cpp:382:20: warning: attempt to free a non-heap object ‘index_arr’ [-Wfree-nonheap-object]
     free(index_arr);
                    ^
host/src/host.cpp:383:21: warning: attempt to free a non-heap object ‘array_dist’ [-Wfree-nonheap-object]
     free(array_dist);

What is the definition of data_point, host_output, etc.?


    int host_output[4344];
    int k = 3;
    int data_point[20] = {};
    for (int i = 0; i < 4344; ++i) {
        for (int j = 0; j < 20; ++j) {
            data_point[j] = array_X_set[i][j];
        }
    }
     int index_arr[4344] = {};
     float array_dist[4344] = {};

Those are not pointers allocated via malloc(). You don’t have to free() them. Those are static arrays. So please just delete your free() calls. This is how it works:

https://www.tutorialspoint.com/c_standard_library/c_function_malloc.htm

@12345hhh, your question has nothing to do with OpenCL. And in the last post of yours I responded to, it appeared you hadn’t even investigated the OpenCL API return values. In another recent thread, you’re asking about how to use basic system build tools and how to link a basic C program.

These forums are for support using Khronos APIs such as OpenCL. They are not general “how to write code” forums.

Please go run through some C tutorials to become more proficient with writing, compiling, and debugging basic C programs first, and then return to OpenCL.

Then, for questions specifically about using Khronos APIs such as OpenCL, read:

for tips on composing your posts.