Paul Eggert wrote: > That reminds me; fts.c violates C89 in a couple of places, which could > lead to core dumps on unusual hosts where void * and FTSENT const ** > have differing runtime representations. I installed this patch into > coreutils. > > +static int > +fts_compar (void const *a, void const *b) > +{ > + /* Convert A and B to the correct types, to pacify the compiler, and > + for portability to bizarre hosts where "void const *" and "FTSENT > + const **" differ in runtime representation. The comparison > + function cannot modify *a and *b, but there is no compile-time > + check for this. */ > + FTSENT const **pa = (FTSENT const **) a; > + FTSENT const **pb = (FTSENT const **) b; > + return pa[0]->fts_fts->fts_compar (pa, pb); > +}
The cost of an extra function call per comparison is pretty high, just to get rid of a cast that will most likely never lead to any damage. (I have not yet seen any platform where the ABI treats 'void *' pointers differently than any data pointers. The basic reason that 'void *' exists at all in C is to permit this kind of cast.) Therefore I would conditionalize this extra function indirection with #ifdef PREFER_RUNTIME_OVERHEAD_OVER_CAST or similar, so that it is disabled by default. Bruno _______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib