After switching to F31 beta I came across a GCC warning that looks like it is useful, trying to warn about misguided uses of the G_CONST_RETURN macro from glib-2.0. However, it leaves me puzzled:
$ cat test.c #include "glib.h" G_CONST_RETURN char * f();
On F30:
~ gcc --version gcc (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1) Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ gcc $(pkg-config -cflags glib-2.0) -c test.c
works fine. On F31 beta,
~ gcc --version gcc (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1) Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ gcc $(pkg-config -cflags glib-2.0) -c test.c test.c:2:13: warning: const 2 | G_CONST_RETURN char * f(); | ^~~~~~~
emits a cryptic warning (and gets the positioning of the squiggly underline wrong).
On both F30 and F31, /usr/include/glib-2.0/glib/gmacros.h contains
/* Deprecated -- do not use. */ #ifndef G_DISABLE_DEPRECATED #ifdef G_DISABLE_CONST_RETURNS #define G_CONST_RETURN #else #define G_CONST_RETURN const #endif #endif
so I'm not sure what causes the warning to be emitted on F31 but not on F30.
(https://developer.gnome.org/glib/unstable/glib-Standard-Macros.html#G-CONST-RETURN:CAPS states: "The macro can be used in place of const for functions that return a value that should not be modified." So the intent of the warning appears to be to warn about uses of G_CONST_RETURN that don't make the return type const, but rather make the return type be e.g. pointer-to-const as in my example.)