mate-desktop / pluma

A powerful text editor for MATE
http://www.mate-desktop.org
GNU General Public License v2.0
158 stars 66 forks source link

GCC14 c99 - fails to compile (error: assignment to 'GFile *' {aka 'struct _GFile *'} from incompatible pointer type 'GObject *' {aka 'struct _GObject *'} [-Wincompatible-pointer-types])GCC14 c99 - #693

Closed immolo closed 6 months ago

immolo commented 9 months ago

With the upcoming changes to GCC14 now adding ModernC like LLVM16 did Pluma-1.26.1 fails to compile although the issue is already resolved in 1.27.0.

pluma-file-bookmarks-store.c: In function 'pluma_file_bookmarks_store_get_uri': pluma-file-bookmarks-store.c:853:22: error: assignment to 'GFile ' {aka 'struct _GFile '} from incompatible pointer type 'GObject ' {aka 'struct _GObject '} [-Wincompatible-pointer-types] 853 | file = g_object_ref (obj); | ^ make[4]: [Makefile:614: pluma-file-bookmarks-store.lo] Error 1 make[4]: Leaving directory '/var/tmp/portage/app-editors/pluma-1.26.0-r2/work/pluma-1.26.0/plugins/filebrowser' make[4]: Waiting for unfinished jobs....

Steps to reproduce:

Compile pluma-1.26.1 with the latest GCC14 snapshot or if using pre 14 then adding -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types to the compiler flags will do the same thing

This is currently being tracked as a Gentoo bug at https://bugs.gentoo.org/919088

NHOrus commented 6 months ago

Bug persists in pluma-1.26.1 Patch https://github.com/mate-desktop/pluma/commit/6bd34181f2490f313a835ce59f82f696c42a2d0a applies cleanly, fixes problem.

lukefromdc commented 6 months ago

C99 is a very old standard we are not really concerned with, it doesn't like "mixed declarations and code." Your patch has the downside of removing initialization of these variables, and would thus need new lines to add that back. In general we are not going to revise all the rest of our code to support the obsolete C99 standard.

NHOrus commented 6 months ago

What. It's your patch. From your repository. That's in 1.27.0 and 1.28.0 It pushes GFile * file declaration way down, mixing it with code. It removes isfs variable completely.

lukefromdc commented 6 months ago

This looks like reducing the scope of variables as advised by cppcheck. Find out why you are compiling with the old C99 standard and don't use any options to treat this warning as an error and see what happens.

NHOrus commented 6 months ago

https://inbox.sourceware.org/gcc-patches/cover.1700473918.git.fweimer@redhat.com/ GCC-14, out in two to four weeks, will turn incompatible pointer types into on-by-default error. Because this kind of type assignment was not permitted in C99 and still not permitted in all C standards that follow

lukefromdc commented 6 months ago

I do not have gcc 14 and also have no experience setting nondefault CFLAGS or build options concerning warnings , so I might have to leave this for the rest of the team.

lukefromdc commented 6 months ago

Looking more closely: this seems to be a simple cherrypick of something we did and evaluated before. The c99 reference basically threw me off of this, as I normally ignore anything that is C99 only. An incompatable pointer type is a whole different issue though, and this should be fixable with a cherrypick to 1.26.

I had mistaken this for an issue against current master and 1.28

lukefromdc commented 6 months ago

Thanks for cherrypicking with https://github.com/mate-desktop/pluma/commit/9f033b7ecb7209174cb8ec0c35e10cf57942398a on Jan 25, looks like what we need is a new 1.26 release so distros can pick it up due to "Bug persists in pluma-1.26.1" the thread on this was very confusing to me

lukefromdc commented 6 months ago

Translations broke on updating for 1.26.2, so I have to revert that update and release 1.26.3 using the same translations as 1.26.1.

Version 1.26.3 with the fix for this included is out and available to distros, so we should be finished with this. Feel free to reopen or to open a new report if gcc-3.14 issues persist