bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* fixes for Clang builtins when compiling Emacs on Fedora
@ 2020-08-17 22:02 Paul Eggert
  2020-08-17 23:37 ` Bruno Haible
  2020-08-23 13:46 ` clang's __diagnose_if__ and glibc fortify Bruno Haible
  0 siblings, 2 replies; 7+ messages in thread
From: Paul Eggert @ 2020-08-17 22:02 UTC (permalink / raw)
  To: Gnulib bugs

[-- Attachment #1: Type: text/plain, Size: 346 bytes --]

I had a couple of problems with the recent Clang-related fixes on Fedora 31 when 
building Emacs, and worked around them by installing the attached patches, which 
I hope are reasonably self-explanatory.

Fedora 31 uses Clang 9, and if the seeming Clang bugs/incompatibilities are 
fixed in later Clang versions I suppose we can do better there.

[-- Attachment #2: 0001-libc-config-avoid-Clang-s-__diagnose_if__.patch --]
[-- Type: text/x-patch, Size: 2259 bytes --]

From a1433e1b1f692c6ae062305d4c683efafb087b38 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 17 Aug 2020 14:45:38 -0700
Subject: [PATCH 1/2] =?UTF-8?q?libc-config:=20avoid=20Clang=E2=80=99s=20?=
 =?UTF-8?q?=5F=5Fdiagnose=5Fif=5F=5F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lib/cdefs.h (__warndecl, __warnattr, __errordecl):
For now, do not use __diagnose_if__ here, as this fails
on Fedora 31 with Clang 9.0.1, with diagnostic
"/usr/include/bits/stdio2.h:263:9: error: fgets called with bigger
size than length of destination buffer
[-Werror,-Wuser-defined-warnings]".  I guess Clang 9 warns even
for functions that are not called?
---
 ChangeLog   | 9 +++++++++
 lib/cdefs.h | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index cd00997a9..ba521c265 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2020-08-17  Paul Eggert  <eggert@cs.ucla.edu>
 
+	libc-config: avoid Clang’s __diagnose_if__
+	* lib/cdefs.h (__warndecl, __warnattr, __errordecl):
+	For now, do not use __diagnose_if__ here, as this fails
+	on Fedora 31 with Clang 9.0.1, with diagnostic
+	"/usr/include/bits/stdio2.h:263:9: error: fgets called with bigger
+	size than length of destination buffer
+	[-Werror,-Wuser-defined-warnings]".  I guess Clang 9 warns even
+	for functions that are not called?
+
 	careadlinkat: speedup for GCC 10 with GCC_LINT
 	Inspired by a suggestion by Bruno Haible in:
 	https://lists.gnu.org/r/bug-gnulib/2020-08/msg00155.html
diff --git a/lib/cdefs.h b/lib/cdefs.h
index 74da73404..32a2c40c6 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -148,7 +148,7 @@
 # define __warnattr(msg) __attribute__((__warning__ (msg)))
 # define __errordecl(name, msg) \
   extern void name (void) __attribute__((__error__ (msg)))
-#elif __glibc_clang_has_attribute (__diagnose_if__)
+#elif __glibc_clang_has_attribute (__diagnose_if__) && 0 /* fails on Fedora 31 with Clang 9.  */
 # define __warndecl(name, msg) \
   extern void name (void) __attribute__((__diagnose_if__ (1, msg, "warning")))
 # define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
-- 
2.17.1


[-- Attachment #3: 0002-verify-avoid-__built_assume-on-Clang.patch --]
[-- Type: text/x-patch, Size: 2687 bytes --]

From 90599fb7db22298ec062a75f10e1a3b4c5578c55 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 17 Aug 2020 14:47:45 -0700
Subject: [PATCH 2/2] verify: avoid __built_assume on Clang
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lib/verify.h (assume): Do not use Clang’s __builtin_assume, as
Clang 9 incorrectly diagnoses arguments as having side effects
even when they do not.  I guess Clang 9 considers any function
call as if it had a side effect here.
---
 ChangeLog    |  6 ++++++
 lib/verify.h | 18 +++++++-----------
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ba521c265..9ba0cda92 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2020-08-17  Paul Eggert  <eggert@cs.ucla.edu>
 
+	verify: avoid __built_assume on Clang
+	* lib/verify.h (assume): Do not use Clang’s __builtin_assume, as
+	Clang 9 incorrectly diagnoses arguments as having side effects
+	even when they do not.  I guess Clang 9 considers any function
+	call as if it had a side effect here.
+
 	libc-config: avoid Clang’s __diagnose_if__
 	* lib/cdefs.h (__warndecl, __warnattr, __errordecl):
 	For now, do not use __diagnose_if__ here, as this fails
diff --git a/lib/verify.h b/lib/verify.h
index 0ba8d5790..d485a0283 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -246,13 +246,6 @@ template <int w>
 
 /* @assert.h omit start@  */
 
-#if defined __has_builtin
-/* <https://clang.llvm.org/docs/LanguageExtensions.html#builtin-functions> */
-# define _GL_HAS_BUILTIN_ASSUME __has_builtin (__builtin_assume)
-#else
-# define _GL_HAS_BUILTIN_ASSUME 0
-#endif
-
 #if 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))
 # define _GL_HAS_BUILTIN_TRAP 1
 #elif defined __has_builtin
@@ -312,11 +305,14 @@ template <int w>
 
    Although assuming R can help a compiler generate better code or
    diagnostics, performance can suffer if R uses hard-to-optimize
-   features such as function calls not inlined by the compiler.  */
+   features such as function calls not inlined by the compiler.
+
+   Avoid Clang’s __builtin_assume, as clang 9.0.1 -Wassume can
+   generate a bogus diagnostic "the argument to '__builtin_assume' has
+   side effects that will be discarded" even when the argument has no
+   side effects.  */
 
-#if _GL_HAS_BUILTIN_ASSUME
-# define assume(R) __builtin_assume (R)
-#elif _GL_HAS_BUILTIN_UNREACHABLE
+#if _GL_HAS_BUILTIN_UNREACHABLE
 # define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
 #elif 1200 <= _MSC_VER
 # define assume(R) __assume (R)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: fixes for Clang builtins when compiling Emacs on Fedora
  2020-08-17 22:02 fixes for Clang builtins when compiling Emacs on Fedora Paul Eggert
@ 2020-08-17 23:37 ` Bruno Haible
  2020-08-18  1:10   ` Paul Eggert
  2020-08-23 13:46 ` clang's __diagnose_if__ and glibc fortify Bruno Haible
  1 sibling, 1 reply; 7+ messages in thread
From: Bruno Haible @ 2020-08-17 23:37 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

Hi Paul,

> I had a couple of problems with the recent Clang-related fixes on Fedora 31 when 
> building Emacs, and worked around them by installing the attached patches

Yes, things are a bit more complicated in practice than in theory... I have just
completed the testing on FreeBSD 12, and will test on OpenBSD and macOS next.

> +	libc-config: avoid Clang’s __diagnose_if__
> +	* lib/cdefs.h (__warndecl, __warnattr, __errordecl):
> +	For now, do not use __diagnose_if__ here, as this fails
> +	on Fedora 31 with Clang 9.0.1, with diagnostic
> +	"/usr/include/bits/stdio2.h:263:9: error: fgets called with bigger
> +	size than length of destination buffer

This is a pity, because these user-defined diagnostics are useful, and
clang does not have __attribute__((__warning__ ...)) that GCC has.

This piece of code in stdio2.h looks like this:

extern char *__REDIRECT (__fgets_chk_warn,
                         (char *__restrict __s, size_t __size, int __n,
                          FILE *__restrict __stream), __fgets_chk)
     __wur __warnattr ("fgets called with bigger size than length "
                       "of destination buffer");

__fortify_function __wur char *
fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
{
  if (__bos (__s) != (size_t) -1)
    {
      if (!__builtin_constant_p (__n) || __n <= 0)
        return __fgets_chk (__s, __bos (__s), __n, __stream);

      if ((size_t) __n > __bos (__s))
        return __fgets_chk_warn (__s, __bos (__s), __n, __stream);  // <=== line 263
    }
  return __fgets_alias (__s, __n, __stream);
}

Most likely the cause is that __bos (__s) currently evaluates to 0,
because I did not port the __bos macro, because the corresponding
attribute works differently in clang than in GCC
<https://clang.llvm.org/docs/AttributeReference.html#alloc-size>.

If you have time to finish this corner of clang support, please go
ahead!

> +   Avoid Clang’s __builtin_assume, as clang 9.0.1 -Wassume can
> +   generate a bogus diagnostic "the argument to '__builtin_assume' has
> +   side effects that will be discarded" even when the argument has no
> +   side effects.  */

Do you have a test case, that we could check on clang 10 and on future
clang versions?

Bruno



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: fixes for Clang builtins when compiling Emacs on Fedora
  2020-08-17 23:37 ` Bruno Haible
@ 2020-08-18  1:10   ` Paul Eggert
  2020-08-22 10:30     ` Clang __built_assume Bruno Haible
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Eggert @ 2020-08-18  1:10 UTC (permalink / raw)
  To: Bruno Haible; +Cc: bug-gnulib

On 8/17/20 4:37 PM, Bruno Haible wrote:
>> +   Avoid Clang’s __builtin_assume, as clang 9.0.1 -Wassume can
>> +   generate a bogus diagnostic "the argument to '__builtin_assume' has
>> +   side effects that will be discarded" even when the argument has no
>> +   side effects.  */
> Do you have a test case, that we could check on clang 10 and on future
> clang versions?

Here's a short test that elicits the bogus warning for me now.

static int f (int x) { return x; }
int main (void) { __builtin_assume (f (1)); return 0; }


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Clang __built_assume
  2020-08-18  1:10   ` Paul Eggert
@ 2020-08-22 10:30     ` Bruno Haible
  2020-08-22 17:32       ` Paul Eggert
  0 siblings, 1 reply; 7+ messages in thread
From: Bruno Haible @ 2020-08-22 10:30 UTC (permalink / raw)
  To: Paul Eggert; +Cc: bug-gnulib

Paul Eggert wrote:
> On 8/17/20 4:37 PM, Bruno Haible wrote:
> >> +   Avoid Clang’s __builtin_assume, as clang 9.0.1 -Wassume can
> >> +   generate a bogus diagnostic "the argument to '__builtin_assume' has
> >> +   side effects that will be discarded" even when the argument has no
> >> +   side effects.  */
> > Do you have a test case, that we could check on clang 10 and on future
> > clang versions?
> 
> Here's a short test that elicits the bogus warning for me now.
> 
> static int f (int x) { return x; }
> int main (void) { __builtin_assume (f (1)); return 0; }

Thanks. I confirm it's still the same with clang 10.

But a small modification of the test case produces no warning:

  static __attribute__ ((__const__)) int f (int x) { return x; }
  int main (void) { __builtin_assume (f (1)); return 0; }

I find it quite natural that

  * If you want to tell the compiler that it can make assumptions about
    a function call, the compiler can evaluate the function call at
    compile-time. If you don't want this, write
      static int f (int x) { return x; }
      int main (void) { int r = f (1); __builtin_assume (r); return 0; }

  * You need to mark those functions that the compiler may evaluate
    at compile-time.

  * There is a diagnostic if the compiler can't take benefit of the
    __builtin_assume invocation, although you intended it to have some.

So, I don't think the warning is bogus.

Back to the verify module. The warning tells us to move the side effect
outside of __builtin_assume. If I do this, I get an assume() macro that

  * produces no warning,

  * in clang versions < 9, has the desired optimization effect, whereas
    the current definition doesn't.

Test case:
==================================================================
#if 1
/* Current definition */
# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
#else
/* Proposed definition */
# define assume(R) \
    ((void) ({ __typeof__ (R) _gl_verify_temp = (R); \
               __builtin_assume (_gl_verify_temp); }))
#endif

static int f (int x) { return x; }
int main (void) { assume (f (1)); return 0; }

int g (int x)
{
  assume (x >= 4);
  return (x > 1 ? x + 3 : 2 * x + 10);
}
==================================================================

With clang 8 and the current definition:

g:                                      # @g
        leal    3(%rdi), %ecx
        cmpl    $1, %edi
        leal    10(%rdi,%rdi), %eax
        cmovgl  %ecx, %eax
        retq

With clang 8 and the proposed definition:

g:                                      # @g
        leal    3(%rdi), %eax
        retq


Here's a proposed patch.


2020-08-22  Bruno Haible  <bruno@clisp.org>

	verify: Do use __built_assume on clang.
	* lib/verify.h (assume): Use clang’s __builtin_assume, with a temporary
	variable in a statement expression.

diff --git a/lib/verify.h b/lib/verify.h
index d485a02..0f3c6f9 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -246,6 +246,13 @@ template <int w>
 
 /* @assert.h omit start@  */
 
+#if defined __has_builtin
+/* <https://clang.llvm.org/docs/LanguageExtensions.html#builtin-functions> */
+# define _GL_HAS_BUILTIN_ASSUME __has_builtin (__builtin_assume)
+#else
+# define _GL_HAS_BUILTIN_ASSUME 0
+#endif
+
 #if 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))
 # define _GL_HAS_BUILTIN_TRAP 1
 #elif defined __has_builtin
@@ -305,14 +312,16 @@ template <int w>
 
    Although assuming R can help a compiler generate better code or
    diagnostics, performance can suffer if R uses hard-to-optimize
-   features such as function calls not inlined by the compiler.
-
-   Avoid Clang’s __builtin_assume, as clang 9.0.1 -Wassume can
-   generate a bogus diagnostic "the argument to '__builtin_assume' has
-   side effects that will be discarded" even when the argument has no
-   side effects.  */
-
-#if _GL_HAS_BUILTIN_UNREACHABLE
+   features such as function calls not inlined by the compiler.  */
+
+#if _GL_HAS_BUILTIN_ASSUME
+/* Use a temporary variable, to avoid a clang warning
+   "the argument to '__builtin_assume' has side effects that will be discarded"
+   if R contains invocations of functions not marked as 'const'.  */
+# define assume(R) \
+    ((void) ({ __typeof__ (R) _gl_verify_temp = (R); \
+               __builtin_assume (_gl_verify_temp); }))
+#elif _GL_HAS_BUILTIN_UNREACHABLE
 # define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
 #elif 1200 <= _MSC_VER
 # define assume(R) __assume (R)



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: Clang __built_assume
  2020-08-22 10:30     ` Clang __built_assume Bruno Haible
@ 2020-08-22 17:32       ` Paul Eggert
  2020-08-22 23:01         ` Clang __builtin_assume Bruno Haible
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Eggert @ 2020-08-22 17:32 UTC (permalink / raw)
  To: Bruno Haible; +Cc: bug-gnulib

On 8/22/20 3:30 AM, Bruno Haible wrote:
> -#if _GL_HAS_BUILTIN_UNREACHABLE
> +   features such as function calls not inlined by the compiler.  */
> +
> +#if _GL_HAS_BUILTIN_ASSUME
> +/* Use a temporary variable, to avoid a clang warning
> +   "the argument to '__builtin_assume' has side effects that will be discarded"
> +   if R contains invocations of functions not marked as 'const'.  */
> +# define assume(R) \
> +    ((void) ({ __typeof__ (R) _gl_verify_temp = (R); \
> +               __builtin_assume (_gl_verify_temp); }))
> +#elif _GL_HAS_BUILTIN_UNREACHABLE
>   # define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())

This is OK, but please also mention in the comment that __builtin_assume 
generates better code for Clang 8 than __builtin_unreachable does, as that's the 
only reason to put up with all this mess.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Clang __builtin_assume
  2020-08-22 17:32       ` Paul Eggert
@ 2020-08-22 23:01         ` Bruno Haible
  0 siblings, 0 replies; 7+ messages in thread
From: Bruno Haible @ 2020-08-22 23:01 UTC (permalink / raw)
  To: Paul Eggert; +Cc: bug-gnulib

> This is OK, but please also mention in the comment that __builtin_assume 
> generates better code for Clang 8 than __builtin_unreachable does, as that's the 
> only reason to put up with all this mess.

Done, as follows:


2020-08-22  Bruno Haible  <bruno@clisp.org>

	verify: Do use __builtin_assume on clang.
	* lib/verify.h (assume): Use clang’s __builtin_assume, with a temporary
	variable in a statement expression.

diff --git a/lib/verify.h b/lib/verify.h
index d485a02..04bb2df 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -246,6 +246,13 @@ template <int w>
 
 /* @assert.h omit start@  */
 
+#if defined __has_builtin
+/* <https://clang.llvm.org/docs/LanguageExtensions.html#builtin-functions> */
+# define _GL_HAS_BUILTIN_ASSUME __has_builtin (__builtin_assume)
+#else
+# define _GL_HAS_BUILTIN_ASSUME 0
+#endif
+
 #if 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))
 # define _GL_HAS_BUILTIN_TRAP 1
 #elif defined __has_builtin
@@ -305,14 +312,21 @@ template <int w>
 
    Although assuming R can help a compiler generate better code or
    diagnostics, performance can suffer if R uses hard-to-optimize
-   features such as function calls not inlined by the compiler.
-
-   Avoid Clang’s __builtin_assume, as clang 9.0.1 -Wassume can
-   generate a bogus diagnostic "the argument to '__builtin_assume' has
-   side effects that will be discarded" even when the argument has no
-   side effects.  */
-
-#if _GL_HAS_BUILTIN_UNREACHABLE
+   features such as function calls not inlined by the compiler.  */
+
+/* Use __builtin_assume in preference to __builtin_unreachable, because
+   in clang versions 8.0.x and older, the definition based on
+   __builtin_assume has an effect on optimizations, whereas the definition
+   based on __builtin_unreachable does not.  (GCC so far has only
+   __builtin_unreachable.)  */
+#if _GL_HAS_BUILTIN_ASSUME
+/* Use a temporary variable, to avoid a clang warning
+   "the argument to '__builtin_assume' has side effects that will be discarded"
+   if R contains invocations of functions not marked as 'const'.  */
+# define assume(R) \
+    ((void) ({ __typeof__ (R) _gl_verify_temp = (R); \
+               __builtin_assume (_gl_verify_temp); }))
+#elif _GL_HAS_BUILTIN_UNREACHABLE
 # define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
 #elif 1200 <= _MSC_VER
 # define assume(R) __assume (R)



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* clang's __diagnose_if__ and glibc fortify
  2020-08-17 22:02 fixes for Clang builtins when compiling Emacs on Fedora Paul Eggert
  2020-08-17 23:37 ` Bruno Haible
@ 2020-08-23 13:46 ` Bruno Haible
  1 sibling, 0 replies; 7+ messages in thread
From: Bruno Haible @ 2020-08-23 13:46 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

[-- Attachment #1: Type: text/plain, Size: 4092 bytes --]

Paul Eggert wrote:
>+	libc-config: avoid Clang’s __diagnose_if__
>+	* lib/cdefs.h (__warndecl, __warnattr, __errordecl):
>+	For now, do not use __diagnose_if__ here, as this fails
>+	on Fedora 31 with Clang 9.0.1, with diagnostic
>+	"/usr/include/bits/stdio2.h:263:9: error: fgets called with bigger
>+	size than length of destination buffer
>+	[-Werror,-Wuser-defined-warnings]".  I guess Clang 9 warns even
>+	for functions that are not called?

I can reproduce the redundant warnings, on Fedora 31 with Clang 9.0.1, when
applying the change to gnulib/lib/cdefs.h also to /usr/include/sys/cdefs.h.

With the attached program foo.c I get warnings for each of these inline
functions that conditionally invokes a *_chk_warn function.

Apparently, clang - unlike GCC - processes the body of the inline function
also when the inline function is never referenced.

It would be possible to silence these warnings by adding a gnulib module
as attached (clang-warnings.tar.gz).

BUT since the macros __warndecl and __warnattr are ONLY used by Fortify
inline functions - there are no other uses in the glibc headers, nor in gnulib -
and most of these uses produce redundant warnings, this is all pointless.

What matters for user code is that gnulib's "attribute.h" defines
ATTRIBUTE_WARNING and ATTRIBUTE_ERROR in a way that works with clang.

In order to use the clang __diagnose_if__ primitive, the Fortify inline
functions would need to be written in a different way. This has been done
in the Android header files. For example, here is the fgets function in
glibc - tailored for GCC -:

extern char *__REDIRECT (__fgets_chk_warn,
                         (char *__restrict __s, size_t __size, int __n,
                          FILE *__restrict __stream), __fgets_chk)
     __wur __warnattr ("fgets called with bigger size than length "
                       "of destination buffer");

__fortify_function __wur char *
fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
{
  if (__bos (__s) != (size_t) -1)
    {
      if (!__builtin_constant_p (__n) || __n <= 0)
        return __fgets_chk (__s, __bos (__s), __n, __stream);

      if ((size_t) __n > __bos (__s))
        return __fgets_chk_warn (__s, __bos (__s), __n, __stream);  // <=== line 263
    }
  return __fgets_alias (__s, __n, __stream);
}

and here it is in Android - tailored for clang -:

__BIONIC_FORTIFY_INLINE
char* fgets(char* const __pass_object_size dest, int size, FILE* stream)
        __overloadable
        __clang_error_if(size < 0, "in call to 'fgets', size should not be negative")
        __clang_error_if(size > __bos(dest),
                         "in call to 'fgets', size is larger than the destination buffer") {
    size_t bos = __bos(dest);

    if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
        return __call_bypassing_fortify(fgets)(dest, size, stream);
    }

    return __fgets_chk(dest, size, stream, bos);
}


2020-08-23  Bruno Haible  <bruno@clisp.org>

	libc-config: Improve comments.
	* lib/cdefs.h (__warndecl, __warnattr, __errordecl): Explain why we
	cannot use clang's __diagnose_if__ here.

diff --git a/lib/cdefs.h b/lib/cdefs.h
index 32a2c40..1ae9ffc 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -148,7 +148,11 @@
 # define __warnattr(msg) __attribute__((__warning__ (msg)))
 # define __errordecl(name, msg) \
   extern void name (void) __attribute__((__error__ (msg)))
-#elif __glibc_clang_has_attribute (__diagnose_if__) && 0 /* fails on Fedora 31 with Clang 9.  */
+#elif __glibc_clang_has_attribute (__diagnose_if__) && 0
+/* These definitions are not enabled, because they produce bogus warnings
+   in the glibc Fortify functions.  These functions are written in a style
+   that works with GCC.  In order to work with clang, these functions would
+   need to be modified.  */
 # define __warndecl(name, msg) \
   extern void name (void) __attribute__((__diagnose_if__ (1, msg, "warning")))
 # define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))


[-- Attachment #2: foo.c --]
[-- Type: text/x-csrc, Size: 325 bytes --]

#include <fcntl.h>
#include <mqueue.h>
#include <poll.h>
#include <sys/socket.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/syslog.h>
#include <unistd.h>
#include <wchar.h>

int main (void)
{
    char buf[80];
    char *p = fgets (buf, 80, stdin);
    printf ("%s\n", p);
}

[-- Attachment #3: foo-warnings.txt --]
[-- Type: text/plain, Size: 21858 bytes --]

In file included from foo.c:3:
In file included from /usr/include/poll.h:1:
In file included from /usr/include/sys/poll.h:73:
/usr/include/bits/poll2.h:43:9: warning: poll called with fds buffer too small file nfds entries [-Wuser-defined-warnings]
        return __poll_chk_warn (__fds, __nfds, __timeout, __bos (__fds));
               ^
/usr/include/bits/poll2.h:33:3: note: from 'diagnose_if' attribute on '__poll_chk_warn':
  __warnattr ("poll called with fds buffer too small file nfds entries");
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:4:
In file included from /usr/include/sys/socket.h:269:
/usr/include/bits/socket2.h:42:9: warning: recv called with bigger length than size of destination buffer [-Wuser-defined-warnings]
        return __recv_chk_warn (__fd, __buf, __n, __bos0 (__buf), __flags);
               ^
/usr/include/bits/socket2.h:30:6: note: from 'diagnose_if' attribute on '__recv_chk_warn':
     __warnattr ("recv called with bigger length than size of destination "
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:4:
In file included from /usr/include/sys/socket.h:269:
/usr/include/bits/socket2.h:73:9: warning: recvfrom called with bigger length than size of destination buffer [-Wuser-defined-warnings]
        return __recvfrom_chk_warn (__fd, __buf, __n, __bos0 (__buf), __flags,
               ^
/usr/include/bits/socket2.h:60:6: note: from 'diagnose_if' attribute on '__recvfrom_chk_warn':
     __warnattr ("recvfrom called with bigger length than size of "
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:5:
In file included from /usr/include/stdio.h:867:
/usr/include/bits/stdio2.h:263:9: warning: fgets called with bigger size than length of destination buffer [-Wuser-defined-warnings]
        return __fgets_chk_warn (__s, __bos (__s), __n, __stream);
               ^
/usr/include/bits/stdio2.h:251:12: note: from 'diagnose_if' attribute on '__fgets_chk_warn':
     __wur __warnattr ("fgets called with bigger size than length "
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:5:
In file included from /usr/include/stdio.h:867:
/usr/include/bits/stdio2.h:295:9: warning: fread called with bigger size * nmemb than length of destination buffer [-Wuser-defined-warnings]
        return __fread_chk_warn (__ptr, __bos0 (__ptr), __size, __n, __stream);
               ^
/usr/include/bits/stdio2.h:280:12: note: from 'diagnose_if' attribute on '__fread_chk_warn':
     __wur __warnattr ("fread called with bigger size * nmemb than length "
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:5:
In file included from /usr/include/stdio.h:867:
/usr/include/bits/stdio2.h:357:9: warning: fread_unlocked called with bigger size * nmemb than length of destination buffer [-Wuser-defined-warnings]
        return __fread_unlocked_chk_warn (__ptr, __bos0 (__ptr), __size, __n,
               ^
/usr/include/bits/stdio2.h:341:12: note: from 'diagnose_if' attribute on '__fread_unlocked_chk_warn':
     __wur __warnattr ("fread_unlocked called with bigger size * nmemb than "
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:6:
In file included from /usr/include/stdlib.h:1017:
/usr/include/bits/stdlib.h:71:9: warning: ptsname_r called with buflen bigger than size of buf [-Wuser-defined-warnings]
        return __ptsname_r_chk_warn (__fd, __buf, __buflen, __bos (__buf));
               ^
/usr/include/bits/stdlib.h:60:22: note: from 'diagnose_if' attribute on '__ptsname_r_chk_warn':
     __nonnull ((2)) __warnattr ("ptsname_r called with buflen bigger than "
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:6:
In file included from /usr/include/stdlib.h:1017:
/usr/include/bits/stdlib.h:123:9: warning: mbstowcs called with dst buffer smaller than len * sizeof (wchar_t) [-Wuser-defined-warnings]
        return __mbstowcs_chk_warn (__dst, __src, __len,
               ^
/usr/include/bits/stdlib.h:109:6: note: from 'diagnose_if' attribute on '__mbstowcs_chk_warn':
     __warnattr ("mbstowcs called with dst buffer smaller than len "
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:6:
In file included from /usr/include/stdlib.h:1017:
/usr/include/bits/stdlib.h:152:9: warning: wcstombs called with dst buffer smaller than len [-Wuser-defined-warnings]
        return __wcstombs_chk_warn (__dst, __src, __len, __bos (__dst));
               ^
/usr/include/bits/stdlib.h:141:6: note: from 'diagnose_if' attribute on '__wcstombs_chk_warn':
     __warnattr ("wcstombs called with dst buffer smaller than len");
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:7:
In file included from /usr/include/string.h:494:
/usr/include/bits/string_fortified.h:67:7: warning: memset used with constant zero length parameter; this could be due to transposed parameters [-Wuser-defined-warnings]
      __warn_memset_zero_len ();
      ^
/usr/include/bits/string_fortified.h:26:1: note: from 'diagnose_if' attribute on '__warn_memset_zero_len':
__warndecl (__warn_memset_zero_len,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:134:42: note: expanded from macro '__warndecl'
  extern void name (void) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                         ^                ~
In file included from foo.c:10:
In file included from /usr/include/unistd.h:1166:
/usr/include/bits/unistd.h:42:9: warning: read called with bigger length than size of the destination buffer [-Wuser-defined-warnings]
        return __read_chk_warn (__fd, __buf, __nbytes, __bos0 (__buf));
               ^
/usr/include/bits/unistd.h:30:12: note: from 'diagnose_if' attribute on '__read_chk_warn':
     __wur __warnattr ("read called with bigger length than size of "
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:10:
In file included from /usr/include/unistd.h:1166:
/usr/include/bits/unistd.h:148:9: warning: readlink called with bigger length than size of destination buffer [-Wuser-defined-warnings]
        return __readlink_chk_warn (__path, __buf, __len, __bos (__buf));
               ^
/usr/include/bits/unistd.h:135:31: note: from 'diagnose_if' attribute on '__readlink_chk_warn':
     __nonnull ((1, 2)) __wur __warnattr ("readlink called with bigger length "
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:10:
In file included from /usr/include/unistd.h:1166:
/usr/include/bits/unistd.h:182:9: warning: readlinkat called with bigger length than size of destination buffer [-Wuser-defined-warnings]
        return __readlinkat_chk_warn (__fd, __path, __buf, __len,
               ^
/usr/include/bits/unistd.h:168:31: note: from 'diagnose_if' attribute on '__readlinkat_chk_warn':
     __nonnull ((2, 3)) __wur __warnattr ("readlinkat called with bigger "
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:10:
In file included from /usr/include/unistd.h:1166:
/usr/include/bits/unistd.h:208:9: warning: getcwd caller with bigger length than size of destination buffer [-Wuser-defined-warnings]
        return __getcwd_chk_warn (__buf, __size, __bos (__buf));
               ^
/usr/include/bits/unistd.h:196:12: note: from 'diagnose_if' attribute on '__getcwd_chk_warn':
     __wur __warnattr ("getcwd caller with bigger length than size of "
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:10:
In file included from /usr/include/unistd.h:1166:
/usr/include/bits/unistd.h:225:10: warning: please use getcwd instead, as getwd doesn't specify buffer size [-Wuser-defined-warnings]
  return __getwd_warn (__buf);
         ^
/usr/include/bits/unistd.h:217:28: note: from 'diagnose_if' attribute on '__getwd_warn':
     __nonnull ((1)) __wur __warnattr ("please use getcwd instead, as getwd "
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:10:
In file included from /usr/include/unistd.h:1166:
/usr/include/bits/unistd.h:248:9: warning: confstr called with bigger length than size of destination buffer [-Wuser-defined-warnings]
        return __confstr_chk_warn (__name, __buf, __len, __bos (__buf));
               ^
/usr/include/bits/unistd.h:236:6: note: from 'diagnose_if' attribute on '__confstr_chk_warn':
     __warnattr ("confstr called with bigger length than size of destination "
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:10:
In file included from /usr/include/unistd.h:1166:
/usr/include/bits/unistd.h:273:9: warning: getgroups called with bigger group count than what can fit into destination buffer [-Wuser-defined-warnings]
        return __getgroups_chk_warn (__size, __list, __bos (__list));
               ^
/usr/include/bits/unistd.h:261:12: note: from 'diagnose_if' attribute on '__getgroups_chk_warn':
     __wur __warnattr ("getgroups called with bigger group count than what "
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:10:
In file included from /usr/include/unistd.h:1166:
/usr/include/bits/unistd.h:299:9: warning: ttyname_r called with bigger buflen than size of destination buffer [-Wuser-defined-warnings]
        return __ttyname_r_chk_warn (__fd, __buf, __buflen, __bos (__buf));
               ^
/usr/include/bits/unistd.h:287:22: note: from 'diagnose_if' attribute on '__ttyname_r_chk_warn':
     __nonnull ((2)) __warnattr ("ttyname_r called with bigger buflen than "
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:10:
In file included from /usr/include/unistd.h:1166:
/usr/include/bits/unistd.h:325:9: warning: getlogin_r called with bigger buflen than size of destination buffer [-Wuser-defined-warnings]
        return __getlogin_r_chk_warn (__buf, __buflen, __bos (__buf));
               ^
/usr/include/bits/unistd.h:313:22: note: from 'diagnose_if' attribute on '__getlogin_r_chk_warn':
     __nonnull ((1)) __warnattr ("getlogin_r called with bigger buflen than "
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:10:
In file included from /usr/include/unistd.h:1166:
/usr/include/bits/unistd.h:352:9: warning: gethostname called with bigger buflen than size of destination buffer [-Wuser-defined-warnings]
        return __gethostname_chk_warn (__buf, __buflen, __bos (__buf));
               ^
/usr/include/bits/unistd.h:340:22: note: from 'diagnose_if' attribute on '__gethostname_chk_warn':
     __nonnull ((1)) __warnattr ("gethostname called with bigger buflen than "
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:10:
In file included from /usr/include/unistd.h:1166:
/usr/include/bits/unistd.h:381:9: warning: getdomainname called with bigger buflen than size of destination buffer [-Wuser-defined-warnings]
        return __getdomainname_chk_warn (__buf, __buflen, __bos (__buf));
               ^
/usr/include/bits/unistd.h:368:28: note: from 'diagnose_if' attribute on '__getdomainname_chk_warn':
     __nonnull ((1)) __wur __warnattr ("getdomainname called with bigger "
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:11:
In file included from /usr/include/wchar.h:848:
/usr/include/bits/wchar2.h:49:9: warning: wmemcpy called with length bigger than size of destination buffer [-Wuser-defined-warnings]
        return __wmemcpy_chk_warn (__s1, __s2, __n,
               ^
/usr/include/bits/wchar2.h:35:6: note: from 'diagnose_if' attribute on '__wmemcpy_chk_warn':
     __warnattr ("wmemcpy called with length bigger than size of destination "
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:11:
In file included from /usr/include/wchar.h:848:
/usr/include/bits/wchar2.h:77:9: warning: wmemmove called with length bigger than size of destination buffer [-Wuser-defined-warnings]
        return __wmemmove_chk_warn (__s1, __s2, __n,
               ^
/usr/include/bits/wchar2.h:64:6: note: from 'diagnose_if' attribute on '__wmemmove_chk_warn':
     __warnattr ("wmemmove called with length bigger than size of destination "
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:11:
In file included from /usr/include/wchar.h:848:
/usr/include/bits/wchar2.h:137:9: warning: wmemset called with length bigger than size of destination buffer [-Wuser-defined-warnings]
        return __wmemset_chk_warn (__s, __c, __n,
               ^
/usr/include/bits/wchar2.h:125:6: note: from 'diagnose_if' attribute on '__wmemset_chk_warn':
     __warnattr ("wmemset called with length bigger than size of destination "
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:11:
In file included from /usr/include/wchar.h:848:
/usr/include/bits/wchar2.h:200:9: warning: wcsncpy called with length bigger than size of destination buffer [-Wuser-defined-warnings]
        return __wcsncpy_chk_warn (__dest, __src, __n,
               ^
/usr/include/bits/wchar2.h:187:6: note: from 'diagnose_if' attribute on '__wcsncpy_chk_warn':
     __warnattr ("wcsncpy called with length bigger than size of destination "
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:11:
In file included from /usr/include/wchar.h:848:
/usr/include/bits/wchar2.h:231:9: warning: wcpncpy called with length bigger than size of destination buffer [-Wuser-defined-warnings]
        return __wcpncpy_chk_warn (__dest, __src, __n,
               ^
/usr/include/bits/wchar2.h:218:6: note: from 'diagnose_if' attribute on '__wcpncpy_chk_warn':
     __warnattr ("wcpncpy called with length bigger than size of destination "
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:11:
In file included from /usr/include/wchar.h:848:
/usr/include/bits/wchar2.h:393:9: warning: fgetws called with bigger size than length of destination buffer [-Wuser-defined-warnings]
        return __fgetws_chk_warn (__s, __bos (__s) / sizeof (wchar_t),
               ^
/usr/include/bits/wchar2.h:380:12: note: from 'diagnose_if' attribute on '__fgetws_chk_warn':
     __wur __warnattr ("fgetws called with bigger size than length "
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:11:
In file included from /usr/include/wchar.h:848:
/usr/include/bits/wchar2.h:484:9: warning: mbsrtowcs called with dst buffer smaller than len * sizeof (wchar_t) [-Wuser-defined-warnings]
        return __mbsrtowcs_chk_warn (__dst, __src, __len, __ps,
               ^
/usr/include/bits/wchar2.h:470:6: note: from 'diagnose_if' attribute on '__mbsrtowcs_chk_warn':
     __warnattr ("mbsrtowcs called with dst buffer smaller than len "
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
In file included from foo.c:11:
In file included from /usr/include/wchar.h:848:
/usr/include/bits/wchar2.h:517:9: warning: wcsrtombs called with dst buffer smaller than len [-Wuser-defined-warnings]
        return __wcsrtombs_chk_warn (__dst, __src, __len, __ps, __bos (__dst));
               ^
/usr/include/bits/wchar2.h:505:5: note: from 'diagnose_if' attribute on '__wcsrtombs_chk_warn':
    __warnattr ("wcsrtombs called with dst buffer smaller than len");
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:135:41: note: expanded from macro '__warnattr'
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
                                        ^                ~
29 warnings generated.

[-- Attachment #4: clang-warnings.tar.gz --]
[-- Type: application/x-compressed-tar, Size: 1653 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-08-23 13:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-17 22:02 fixes for Clang builtins when compiling Emacs on Fedora Paul Eggert
2020-08-17 23:37 ` Bruno Haible
2020-08-18  1:10   ` Paul Eggert
2020-08-22 10:30     ` Clang __built_assume Bruno Haible
2020-08-22 17:32       ` Paul Eggert
2020-08-22 23:01         ` Clang __builtin_assume Bruno Haible
2020-08-23 13:46 ` clang's __diagnose_if__ and glibc fortify Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).