This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] dlfcn: Avoid one-element flexible array in Dl_serinfo
On Thu, 23 May 2019, Paul Eggert wrote:
> On 5/23/19 2:34 AM, Florian Weimer wrote:
> > +# ifdef __GNUC__
> > + /* This avoids an unwanted array subscript check by the compiler,
> > + while preserving the size of the type. */
> > + __extension__ union
> > + {
> > + Dl_serpath dls_serpath[0]; /* Actually longer, dls_cnt elements. */
> > + Dl_serpath __dls_serpath_pad[1];
> > + };
> > +# else /* !__GNUC__ */
> > Dl_serpath dls_serpath[1]; /* Actually longer, dls_cnt elements.
> > */
> > +# endif /* !__GNUC__ */
>
> Since this is actually a flexible array member, shouldn't we be using C99's
> support for that if available, instead? Something like the attached untested
> patch, say. We've been using a FLEXIBLE_ARRAY_MEMBER macro in Gnulib for quite
> some time to do this sort of thing.
Since we already have the __flexarr macro in sys/cdefs.h, I don't think
having a slightly different __GLIBC_FLEXIBLE_ARRAY_MEMBER as well seems
like a good idea.
--
Joseph S. Myers
joseph@codesourcery.com