bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Cc: Paul Eggert <eggert@cs.ucla.edu>
Subject: clang's __diagnose_if__ and glibc fortify
Date: Sun, 23 Aug 2020 15:46:50 +0200	[thread overview]
Message-ID: <7776169.abOZdhWsUJ@omega> (raw)
In-Reply-To: <5e607e6f-ee3a-41bc-67eb-cdc0571d00d0@cs.ucla.edu>

[-- 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 --]

      parent reply	other threads:[~2020-08-23 13:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Bruno Haible [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7776169.abOZdhWsUJ@omega \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=eggert@cs.ucla.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).