I’ve never used it in my code before __attribute__ ((__malloc__)).
There are several cases, for example:
reallocarray
has __malloc__ (__builtin_free, 1)
and is second function reallocarray
differs only by attributes.
This is only information to optimization? but fopen
has __attribute__ ((__malloc__ (fclose, 1))
Problem that clang++ called
clang++ -std=c++20 -fmodules-ts --precompile -x c+±module hello.cpp.i
give errors:
In file included from /home/andrzej/wazne/gitmy/my_c/modules/bazel/normalnie/hello.cpp:2:
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41:
In file included from /usr/include/c++/11/cmath:47:
In file included from /usr/include/c++/11/bits/std_abs.h:38:
/usr/include/stdlib.h:566:21: error: '__malloc__' attribute takes no arguments
__attribute__ ((__malloc__ (__builtin_free, 1)));
^
/usr/include/stdlib.h:570:38: error: '__malloc__' attribute takes no arguments
noexcept (true) __attribute__ ((__malloc__ (reallocarray, 1)));
^
/usr/include/stdlib.h:799:22: error: '__malloc__' attribute takes no arguments
__attribute__ ((__malloc__ (__builtin_free, 1))) ;
Where hello.cpp.i is preprocessed followwing file
export module hello;
#include <bits/stdc++.h>
I am trying make modules with fragments of standard library to use it instead #include;
modules not allowed arguments attribute malloc
,
changing
__attribute__ ((__malloc__ (args))
to
__attribute__ ((__malloc__ ())
give only optimization case or problem freeing?