Subject: bug#30913: [bug-diffutils] bug#30913: bug#30913: Releasing a build compatible withglibc-2.26+

From: Jim Meyering <[email-masked]>
Date: Fri, 23 Mar 2018 14:26:10 -0700

On Fri, Mar 23, 2018 at 11:50 AM, Eric Blake <[email-masked]> wrote:
> On 03/23/2018 01:44 PM, Paul Eggert wrote:
>
>>> From 0d111b0de328d31dd3444ceeec977a7aaa5bb0ed Mon Sep 17 00:00:00 2001
>>
>> From: Paul Eggert<[email-masked]>
>> Date: Fri, 23 Mar 2018 11:26:15 -0700
>> Subject: [PATCH] c-stack: port to recent GCC build
>>
>> Problem reported by The Fireplace (Bug#30913).
>> * lib/c-stack.c (die): Define only if used.
>
>
>> +++ b/lib/c-stack.c
>> @@ -99,6 +99,10 @@ static void (* volatile segv_action) (int);
>>   static char const * volatile program_error_message;
>>   static char const * volatile stack_overflow_message;
>>   +#if ((HAVE_LIBSIGSEGV && ! HAVE_XSI_STACK_OVERFLOW_HEURISTIC) \
>> +     || (HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK            \
>> +         && HAVE_STACK_OVERFLOW_HANDLING && SIGINFO_WORKS))
>> +
>
>
> That's a maintenance nightmare to keep the #if conditions in sync. Would it
> not be simpler to just use __attribute__((unused)) on the function
> declaration, to tell the compiler that the function does not get used in all
> setups, but that it should not warn in those cases?

Good point. I think it's safe, these days. At worst,
enable it only for gcc 5.x and newer. Older compilers
should not be used with -Werror.

While not everyone compiles gnulib's regex.c,
I note that it uses the construct via regex_internal.h:

  lib/regex_internal.h:799:static void __attribute__ ((unused))
  lib/regex_internal.h-800-bitset_not (bitset_t set)

with this definition:

  #if __GNUC__ < 3 + (__GNUC_MINOR__ < 1)
  # define __attribute__(arg)
  #endif