glib-2.0 G_CONST_RETURN causing GCC "warning: const' on F31

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.)
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux