On 6/10/19 1:54 PM, Andrew Haley wrote:
> On 6/10/19 8:24 AM, Martin Liška wrote:
> 
>> I've just noticed that we have couple of alloca (0) in libiberty:
>>
>> #ifndef REGEX_MALLOC
>> # ifdef C_ALLOCA
>>       alloca (0);
>> # endif
>> #endif
>>
>> If I'm correct the value 0 has a special meaning that tells a C library
>> to clean up all previous alloca allocations.
>>
>> man alloca does not document the behavior
> 
> I'm sure it doesn't. This alloca(0) behaviour is a libiberty-internal
> thing.
> 
>> Question is how legacy is alloca call from a standard library?
> 
> alloca(3) is implemented by GCC as a builtin. It's fast, simple, and
> widely used. These days you might use variable-length arrays instead,
> which are at least portable.
> 
> Is there some problem that you want to solve?
> 

I see 3 occurrences of the alloca (0) in libiberty/regex.c, but there are 
properly
guarded within:

# ifdef C_ALLOCA
      alloca (0);
# endif

and then I noticed 2 more occurrences in gdb that break build right now:

gdb/regcache.c:  alloca (0);
gdb/top.c:  alloca (0);

Is it the right approach to remove these 2 in gdb?
Martin


Reply via email to