https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119950
Bug ID: 119950
Summary: __builtin_constant_p warning with
-Wdeprecated-non-prototype inconsistent
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: quentin at armitage dot org.uk
Target Milestone: ---
The following code (in /tmp/wc.c) compiles without error:
#define __USE_EXTERN_INLINES
#include <wchar.h>
when compiled with gcc -Wdeprecated-non-prototypes -c -o /tmp/wc.{o,c}
However, if I copy /usr/include/wchar.h to /tmp and change /tmp/wc.c to be:
#define __USE_EXTERN_INLINES
#include </tmp/wchar.h>
compiling now gives the following errors:
In file included from /tmp/wc.c:2:
/tmp/wchar.h: In function ‘btowc’:
/tmp/wchar.h:344:11: warning: ISO C23 does not allow arguments for function
‘__builtin_constant_p’ declared without parameters [-Wdeprecated-non-prototype]
344 | { return (__builtin_constant_p (__c) && __c >= '\0' && __c <= '\x7f'
| ^~~~~~~~~~~~~~~~~~~~
/tmp/wchar.h: In function ‘wctob’:
/tmp/wchar.h:350:11: warning: ISO C23 does not allow arguments for function
‘__builtin_constant_p’ declared without parameters [-Wdeprecated-non-prototype]
350 | { return (__builtin_constant_p (__wc) && __wc >= L'\0' && __wc <=
L'\x7f'
| ^~~~~~~~~~~~~~~~~~~~
The above in itself is clearly not the problem itself, but the problem comes
from including the glib2 headers (from
https://download.gnome.org/sources/glib/2.84/glib-2.84.1.tar.xz) which use
__builtin_constant_p.
Compiling:
#include <gio/gio.h>
with -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
-Wdeprecated-non-prototype generates the following errors:
In file included from /usr/include/glib-2.0/glib/gstring.h:37,
from /usr/include/glib-2.0/glib/giochannel.h:36,
from /usr/include/glib-2.0/glib.h:56,
from /usr/include/glib-2.0/gobject/gbinding.h:30,
from /usr/include/glib-2.0/glib-object.h:24,
from /usr/include/glib-2.0/gio/gioenums.h:30,
from /usr/include/glib-2.0/gio/giotypes.h:30,
from /usr/include/glib-2.0/gio/gio.h:28,
from /tmp/gl.c:1:
/usr/include/glib-2.0/glib/gstrfuncs.h: In function ‘g_strdup_inline’:
/usr/include/glib-2.0/glib/gstrfuncs.h:311:7: warning: ISO C23 does not allow
arguments for function ‘__builtin_constant_p’ declared without parameters
[-Wdeprecated-non-prototype]
311 | if (__builtin_constant_p (!str) && !str)
| ^~~~~~~~~~~~~~~~~~~~
/usr/include/glib-2.0/glib/gstrfuncs.h:314:7: warning: ISO C23 does not allow
arguments for function ‘__builtin_constant_p’ declared without parameters
[-Wdeprecated-non-prototype]
314 | if (__builtin_constant_p (!!str) && !!str && __builtin_constant_p
(strlen (str)))
| ^~~~~~~~~~~~~~~~~~~~
/usr/include/glib-2.0/glib/gstrfuncs.h:314:48: warning: ISO C23 does not allow
arguments for function ‘__builtin_constant_p’ declared without parameters
[-Wdeprecated-non-prototype]
314 | if (__builtin_constant_p (!!str) && !!str && __builtin_constant_p
(strlen (str)))
| ^~~~~~~~~~~~~~~~~~~~
/usr/include/glib-2.0/glib/glib-autocleanups.h: In function
‘g_autoptr_cleanup_gstring_free’:
/usr/include/glib-2.0/glib/gstring.h:72:4: warning: ISO C23 does not allow
arguments for function ‘__builtin_constant_p’ declared without parameters
[-Wdeprecated-non-prototype]
72 | (__builtin_constant_p (free_segment) ? \
| ^~~~~~~~~~~~~~~~~~~~
/usr/include/glib-2.0/glib/glib-autocleanups.h:39:5: note: in expansion of
macro ‘g_string_free’
39 | g_string_free (string, TRUE);