Re: problem building Gnulib libgnu_a-malloca.o with Debian oldstable's clang

Bruno Haible via Gnulib discussion list <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <2753347.jbyF5MZJ3u@cagnes>
Lasse Collin wrote:
> I looked at the root cause. In the Gnulib-generated assert.h in both
> gnu99 and gnu11 modes, these look correct:
> 
>     _GL_HAVE__STATIC_ASSERT is defined.
>     _GL_HAVE__STATIC_ASSERT1 is not defined.
> 
> In gnu11 mode, Gnulib-generated assert.h overrides _Static_assert here:
> 
> # elif !defined _GL_HAVE__STATIC_ASSERT1 && !defined _Static_assert
> #  if !defined _MSC_VER || defined __clang__
> #   define _Static_assert(...) \
>       _GL_STATIC_ASSERT (__VA_ARGS__, "static assertion failed", -)
> 
> However, in gnu99 mode, no overriding happens because <sys/cdefs.h>
> from glibc 2.31 has already defined _Static_assert (the old glibc lacks
> the check for __clang_major__):
> 
> #if (!defined _Static_assert && !defined __cplusplus \
>      && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
>      && (!__GNUC_PREREQ (4, 6) || defined __STRICT_ANSI__))
> # define _Static_assert(expr, diagnostic) \
>     extern int (*__Static_assert_function (void)) \
>       [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
> #endif

Thanks for this analysis!

> I attached patches. The first one adds a comment related to this issue.
> The second patch fixes the groff build (even if ac_cv_prog_cc_c11=no
> isn't removed). I didn't do other testing.

Thanks for the patches. I have applied them:
  - the first one with a slight comment change,
  - the second one with an added '&& !defined __cplusplus', because
    the glibc/misc/sys/cdefs.h condition also contains '&& !defined __cplusplus'
    and such things generally work differently in C++ mode than in C mode.

Bruno
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.