Subject: Re: [PATCH 1/5] compat/obstack: fix -Wcast-function-type warnings

From: SZEDER Gábor <[email-masked]>
Date: Fri, 11 Jan 2019 01:37:43 +0100

On Thu, Jan 10, 2019 at 01:22:00PM -0800, Junio C Hamano wrote:
> Ævar Arnfjörð Bjarmason <[email-masked]> writes:
> 
> > On Thu, Dec 20 2018, SZEDER Gábor wrote:
> >
> >> When building Git with GCC 8.2.0 (at least from Homebrew on macOS,
> >> DEVELOPER flags enabled) one is greeted with a screenful of compiler
> >> errors:
> >>
> >>   compat/obstack.c: In function '_obstack_begin':
> >>   compat/obstack.c:162:17: error: cast between incompatible function types from 'void * (*)(long int)' to 'struct _obstack_chunk * (*)(void *, long int)' [-Werror=cast-function-type]
> >>      h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun;
> >>                    ^
> >>   compat/obstack.c:163:16: error: cast between incompatible function types from 'void (*)(void *)' to 'void (*)(void *, struct _obstack_chunk *)' [-Werror=cast-function-type]
> >>      h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
> >>                   ^
> >>   compat/obstack.c:116:8: error: cast between incompatible function types from 'struct _obstack_chunk * (*)(void *, long int)' to 'struct _obstack_chunk * (*)(long int)' [-Werror=cast-function-type]
> >>       : (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size)))
> >>           ^
> >>   compat/obstack.c:168:22: note: in expansion of macro 'CALL_CHUNKFUN'
> >>      chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
> >>                         ^~~~~~~~~~~~~
> >>   <snip>
> >
> > We originally got this from now-discontinued eglibc, but I notice that
> > glibc.git's malloc/obstack.[ch]'s diff also changes these lines. If you
> > backport those do does that fix this warning?
> >
> > I.e. is this another case where we're blindly fixing bugs but should
> > just re-import upstream's code instead?
> 
> Good point.  I am inclined to queue the remainder of the series
> without this one for now.

Note that without this first patch the linux-gcc build job will fail
with the above compiler error, and that's the only build job that runs
the test suite with all the misc test knobs (split-index,
commit-graph, etc.) enabled.