Szerző: Nuno Lopes Dátum: Címzett: Zoltán Herczeg CC: pcre-dev Tárgy: Re: [pcre-dev] Fw: Re: [PATCH] add malloc and alloc_size attributes
to allocation functions
>> The thing is that PCRE is often built along with other projects. The >> more autoconf magic we add, the worst, since those options are
>> unlikely to be picked up by these projects bundling PCRE. (and I
>
> I totally agree with this. However, adding everything to pcre.h
> makes it far less readable. In sljit, I introduced separate header
> files for compiler magic. And __has_attribute breaks the rule that
> everything must be prefixed by pcre or PCRE.
The __has_attribute macro is special in clang. It's defined by the compiler.
>> This attribute has nothing to do with glibc. It is used by gcc/clang
>> to provide useful warnings for, e.g., array out-of-bounds indexing.
>
> Still seems a research thingy for me. Just out of curiosity did you
> actually captured anything with it in PCRE?
No, nothing appeared in clang, which is a good thing! :)
But it will prevent overflows being introduced in the future.
>> Apart of the warnings, it can be used for optimizations, and run-time
>> code instrumentation.
>
> Actually both in pcre and in sljit, malloc is rarely used by design,
> so I am still unsure about its benefit.
>
> I am not against this feature, but I really would like to see a real
> use case which benefit from adding more symbols to a header file.
> Btw did you try JIT? I suspect it would offer far more speedup than
> any malloc optimization.
I didn't try the JIT compiler. But I'll pass it through clang and I'll
let you know if it finds any bug.
Anyway, the benefits add up. The malloc attribute will be used in JIT
mode as well.