Hi Arnold,
> This code in regex_internal.c:
>
> -------------------------------------
> static reg_errcode_t
> __attribute_warn_unused_result__
> re_node_set_alloc (re_node_set *set, Idx size)
> {
> set->alloc = size;
> set->nelem = 0;
> set->elems = re_malloc (Idx, size);
> if (__glibc_unlikely (set->elems == NULL))
> return REG_ESPACE;
> return REG_NOERROR;
> }
> -------------------------------------
>
> If size is zero, malloc() is called with zero. IIRC, it's formally
> undefined what happens if malloc(0) is called, and NULL is a possibly
> valid result. If used with a malloc() that does return NULL, compilation
> of a regex fails. regex needs to take this into account.
Yes, and it already does: The module 'regex' has a dependency towards
the module 'malloc-gnu'. The module malloc-gnu guarantees that malloc(0)
is non-NULL except in out-of-memory situations.
> This happened in gawk using the Persistent Memory Allocator (PMA).
>
> I have worked around it with additional gawk-specific code that sets
> size to 1 if it's 0.
Yeah, IIRC gawk does not use gnulib-tool and therefore has to do things
differently than gnulib.
Bruno