Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 880617

Summary: x11-libs/gtk+-2.24.33-r2 - /.../gtkscale.c: error: incompatible function pointer types passing GCompareFunc (aka int ( )(const voi
Product: Gentoo Linux Reporter: Toralf Förster <toralf>
Component: Current packagesAssignee: Gentoo Linux Gnome Desktop Team <gnome>
Status: RESOLVED FIXED    
Severity: normal CC: herrtimson, sam
Priority: Normal Keywords: PullRequest
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://github.com/gentoo/gentoo/pull/31021
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 870412    
Attachments: emerge-info.txt
emerge-history.txt
environment
etc.clang.tar.bz2
etc.portage.tar.bz2
logs.tar.bz2
temp.tar.bz2
var.tmp.clang.tar.bz2
x11-libs:gtk+-2.24.33-r2:20221109-152137.log.bz2
function_typecast_fix.patch

Description Toralf Förster gentoo-dev 2022-11-09 15:40:52 UTC
                                ^
<scratch space>:8:6: note: expanded from here
 GCC warning "Deprecated pre-processor symbol: replace with \"G_ADD_PRIVATE\""
     ^
/var/tmp/portage/x11-libs/gtk+-2.24.33-r2/work/gtk+-2.24.33/gtk/gtkscale.c:1474:50: error: incompatible function pointer types passing 'GCompareFunc' (aka 'int (*)(const void *, const void *)') to parameter of type 'GCompareDataFunc' (aka 'int (*)(const void *, const void *, void *)') [-Werror,-Wincompatible-function-pointer-types]
                                                 (GCompareFunc) compare_marks,
                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

  -------------------------------------------------------------------

  This is an unstable amd64 chroot image at a tinderbox (==build bot)
  name: 17.1_desktop_gnome-j4-20221109-090003

  -------------------------------------------------------------------

GNUMAKEFLAGS="$GNUMAKEFLAGS --jobserver-style=pipe"
GNUMAKEFLAGS="$GNUMAKEFLAGS --shuffle"
CC=clang
CXX=clang++
gcc-config -l:
 [1] x86_64-pc-linux-gnu-12 *
clang/llvm (if any):
clang version 15.0.4
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/15/bin
Configuration file: /etc/clang/clang.cfg
/usr/lib/llvm/15
15.0.4
Python 3.10.8
Available Rust versions:
  [1]   rust-bin-1.64.0 *
php cli (if any):

  HEAD of ::gentoo
commit 13b7b1255ae6125608899908b118a34f8a8347f1
Author: Repository mirror & CI <repomirrorci@gentoo.org>
Date:   Wed Nov 9 14:16:53 2022 +0000

    2022-11-09 14:16:52 UTC

emerge -qpvO x11-libs/gtk+
[ebuild   R   ] x11-libs/gtk+-3.24.34-r1  USE="X colord cups introspection sysprof wayland (-aqua) -broadway -examples -gtk-doc -test -vim-syntax -xinerama" ABI_X86="(64) -32 (-x32)"
Comment 1 Toralf Förster gentoo-dev 2022-11-09 15:40:53 UTC
Created attachment 830115 [details]
emerge-info.txt
Comment 2 Toralf Förster gentoo-dev 2022-11-09 15:40:54 UTC
Created attachment 830117 [details]
emerge-history.txt
Comment 3 Toralf Förster gentoo-dev 2022-11-09 15:40:56 UTC
Created attachment 830119 [details]
environment
Comment 4 Toralf Förster gentoo-dev 2022-11-09 15:40:57 UTC
Created attachment 830121 [details]
etc.clang.tar.bz2
Comment 5 Toralf Förster gentoo-dev 2022-11-09 15:40:58 UTC
Created attachment 830123 [details]
etc.portage.tar.bz2
Comment 6 Toralf Förster gentoo-dev 2022-11-09 15:40:59 UTC
Created attachment 830125 [details]
logs.tar.bz2
Comment 7 Toralf Förster gentoo-dev 2022-11-09 15:41:01 UTC
Created attachment 830127 [details]
temp.tar.bz2
Comment 8 Toralf Förster gentoo-dev 2022-11-09 15:41:02 UTC
Created attachment 830129 [details]
var.tmp.clang.tar.bz2
Comment 9 Toralf Förster gentoo-dev 2022-11-09 15:41:04 UTC
Created attachment 830131 [details]
x11-libs:gtk+-2.24.33-r2:20221109-152137.log.bz2
Comment 10 Matt Turner gentoo-dev 2022-11-11 20:10:50 UTC
So the problem is:

> /var/tmp/portage/x11-libs/gtk+-2.24.33-r2/work/gtk+-2.24.33/gtk/gtkscale.c:1474:50: error: incompatible function pointer types passing
> 'GCompareFunc'     (aka 'int (*)(const void *, const void *)') to parameter of type
> 'GCompareDataFunc' (aka 'int (*)(const void *, const void *, void *)')
> [-Werror,-Wincompatible-function-pointer-types]

compare_marks is declared as

> static gint 
> compare_marks (gconstpointer a, gconstpointer b, gpointer data)

g_slist_insert_sorted_with_data takes a GCompareDataFunc:

> GSList*  g_slist_insert_sorted_with_data (GSList           *list,
> 					  gpointer          data,
> 					  GCompareDataFunc  func,
> 					  gpointer          user_data) G_GNUC_WARN_UNUSED_RESULT;

The problem appears to be a stray (and unnecessary) cast to GCompareFunc:

>   priv->marks = g_slist_insert_sorted_with_data (priv->marks, mark,
>                                                  (GCompareFunc) compare_marks,
>                                                  GINT_TO_POINTER (
>                                                    gtk_range_get_inverted (GTK_RANGE (scale)) 
>                                                    ));

We can fix that easily enough, but this is not really the only problem, is it? I see

 * /var/tmp/portage/x11-libs/gtk+-2.24.33-r2/work/gtk+-2.24.33/gtk/gtkcellrendererspin.c:210:26: warning: assignment to 'GtkAdjustment *' {aka 'struct _GtkAdjustment *'} from incompatible pointer type 'GObject *' {aka 'struct _GObject *'} [-Wincompatible-pointer-types]
 * /var/tmp/portage/x11-libs/gtk+-2.24.33-r2/work/gtk+-2.24.33/gtk/gtkcomboboxtext.c:278:27: warning: assignment to 'GObject *' {aka 'struct _GObject *'} from incompatible pointer type 'GtkBuildable *' {aka 'struct _GtkBuildable *'} [-Wincompatible-pointer-types]
 * /var/tmp/portage/x11-libs/gtk+-2.24.33-r2/work/gtk+-2.24.33/gtk/gtkimmodule.c:665:49: warning: passing argument 3 of 'g_hash_table_lookup_extended' from incompatible pointer type [-Wincompatible-pointer-types]
 * /var/tmp/portage/x11-libs/gtk+-2.24.33-r2/work/gtk+-2.24.33/gtk/gtklabel.c:1339:27: warning: assignment to 'GObject *' {aka 'struct _GObject *'} from incompatible pointer type 'GtkBuildable *' {aka 'struct _GtkBuildable *'} [-Wincompatible-pointer-types]
[...]
 * /var/tmp/portage/x11-libs/gtk+-2.24.33-r2/work/gtk+-2.24.33/gtk/gtktoolpalette.c:737:16: warning: assignment to 'GtkToolItemGroup *' {aka 'struct _GtkToolItemGroup *'} from incompatible pointer type 'GtkWidget *' {aka 'struct _GtkWidget *'} [-Wincompatible-pointer-types]
 * /var/tmp/portage/x11-libs/gtk+-2.24.33-r2/work/gtk+-2.24.33/gtk/gtktreeview.c:14150:37: warning: assignment to 'GtkWidget *' {aka 'struct _GtkWidget *'} from incompatible pointer type 'GtkEntry *' {aka 'struct _GtkEntry *'} [-Wincompatible-pointer-types]
 * /usr/include/glib-2.0/gobject/gobject.h:548:28: warning: returning 'GtkWidget *' {aka 'struct _GtkWidget *'} from a function with incompatible return type 'GObject *' {aka 'struct _GObject *'} [-Wincompatible-pointer-types]
 * /var/tmp/portage/x11-libs/gtk+-2.24.33-r2/work/gtk+-2.24.33/gtk/gtkwidget.c:10682:27: warning: assignment to 'GObject *' {aka 'struct _GObject *'} from incompatible pointer type 'GtkBuildable *' {aka 'struct _GtkBuildable *'} [-Wincompatible-pointer-types]
 * /usr/include/glib-2.0/glib/gatomic.h:131:5: warning: argument 2 of '__atomic_load' discards 'volatile' qualifier [-Wincompatible-pointer-types]
 * /var/tmp/portage/x11-libs/gtk+-2.24.33-r2/work/gtk+-2.24.33/modules/other/gail/gailtreeview.c:998:34: warning: assignment to 'AtkObject *' {aka 'struct _AtkObject *'} from incompatible pointer type 'GailCell *' {aka 'struct _GailCell *'} [-Wincompatible-pointer-types]
 * /var/tmp/portage/x11-libs/gtk+-2.24.33-r2/work/gtk+-2.24.33/modules/printbackends/cups/gtkprintbackendcups.c:3482:17: warning: assignment to 'GtkPrinterCups *' {aka 'struct _GtkPrinterCups *'} from incompatible pointer type 'GtkPrinter *' {aka 'struct _GtkPrinter *'} [-Wincompatible-pointer-types]

I'd really rather not get 1 bug for each of these.

I suspect we need to disable the compiler error for dead packages like gtk+:2.
Comment 11 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-05-08 13:01:47 UTC
Note that clang makes -Wincompatible-function-pointer-types an error by default, but not -Wincompatible-pointer-types which is a superset. GCC only supports the latter warning.
Comment 12 nvinson234 2023-05-09 11:51:03 UTC
Created attachment 861378 [details, diff]
function_typecast_fix.patch
Comment 13 listout 2023-05-13 12:48:05 UTC
(In reply to nvinson234 from comment #12)
> Created attachment 861378 [details, diff] [details, diff]
> function_typecast_fix.patch

Tried sending your patch upstream?
Comment 14 Larry the Git Cow gentoo-dev 2023-05-13 16:02:31 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d2cb27c2be5ab925ea43cdd764210dd3c55ace57

commit d2cb27c2be5ab925ea43cdd764210dd3c55ace57
Author:     Matt Turner <mattst88@gentoo.org>
AuthorDate: 2023-05-13 15:55:26 +0000
Commit:     Matt Turner <mattst88@gentoo.org>
CommitDate: 2023-05-13 15:59:20 +0000

    x11-libs/gtk+: Add patch to fix casts
    
    Closes: https://bugs.gentoo.org/880617
    Closes: https://github.com/gentoo/gentoo/pull/31021
    Signed-off-by: Matt Turner <mattst88@gentoo.org>

 x11-libs/gtk+/files/gtk+-2.24.33-Fix-casts.patch | 167 +++++++++++++++++++++++
 x11-libs/gtk+/gtk+-2.24.33-r2.ebuild             |   2 +
 2 files changed, 169 insertions(+)
Comment 15 Matt Turner gentoo-dev 2023-05-13 16:03:50 UTC
I fixed the problem I noted in comment #10 along with a number of other cast warnings. gtk+:2 now compiles with clang with CFLAGS="-Werror=implicit-function-declaration -Werror=implicit-int -Werror=incompatible-function-pointer-types".