After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 570501 - g_win32_get_system_data_dirs uses invalid conversion of function pointer to object pointer
g_win32_get_system_data_dirs uses invalid conversion of function pointer to o...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Win32
2.14.x
Other All
: Normal minor
: ---
Assigned To: gtk-win32 maintainers
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2009-02-04 14:54 UTC by Michael Cronenworth
Modified: 2009-02-23 09:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
my ugly patch (622 bytes, patch)
2009-02-04 14:56 UTC, Michael Cronenworth
none Details | Review
Improved patch (3.65 KB, patch)
2009-02-12 17:46 UTC, Tor Lillqvist
none Details | Review

Description Michael Cronenworth 2009-02-04 14:54:51 UTC
Please describe the problem:
Attempting to build any GTK+ program under Windows using MinGW results in a warning. Example: If your application has 30 source file modules, you will see 30 warnings. Under MSYS this results in about 15 lines worth of crap. It can easily cloud other warnings. I am using -Wall in my CFLAGS. This is the only warning I am receiving.

Warning:
C:/msys/1.0/include/glib-2.0/glib/gutils.h: In function `g_win32_get_system_data_dirs':
C:/msys/1.0/include/glib-2.0/glib/gutils.h:143: warning: ISO C forbids conversion of function pointer to object pointer type

Steps to reproduce:
Compile any GTK+ application in MSYS using MinGW.

Actual results:
Warning thrown.

Expected results:
No warnings.

Does this happen every time?
Yes.

Other information:
This bug is related to bug 173098.
Comment 1 Michael Cronenworth 2009-02-04 14:56:55 UTC
Created attachment 127928 [details] [review]
my ugly patch

I am attaching my (ugly) patch to silence the warning while maintaining ABI type compatibility. Feel free to manipulate it as necessary.
Comment 2 Tor Lillqvist 2009-02-04 14:58:19 UTC
What version of gcc is this, btw? Or do you specifically pass some flag that normally doesn't get used which makes gcc more picky?
Comment 3 Michael Cronenworth 2009-02-04 15:12:57 UTC
Sorry, I should have included that bit of info.

$ gcc -v 
Reading specs from c:/MinGW/bin/../lib/gcc/mingw32/3.4.5/specs
Configured with: ../gcc-3.4.5-20060117-3/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization --enable-libstdcxx-debug
Thread model: win32
gcc version 3.4.5 (mingw-vista special r3)

I am passing -Wall -pedantic -std=c99

It's -pedantic that's exposing this.
Comment 4 Tor Lillqvist 2009-02-12 17:44:41 UTC
Unfortunately your patch removes the -pedantic warning, but it doesn't work.

The point in the original code is to pass to g_win32_get_system_data_dirs_for_module() the address of something that is in the code of the module that the compiled inline g_win32_get_system_data_dirs() function has been linked into. It simply passes the address of itself;) The g_win32_get_system_data_dirs_for_module() function then looks up what module (dll or exe) contains that address.

Your patch passes the random contents of the uninitialized local variable pfn in that function. Note that for instance passing pfn's address would work either, as it is local and thus on the stack and not in the code (or read-only data) of any module. Having a static const int variable and passing its address might work, but I wouldn't count on it.

Instead, to avoid the warning, it should be enough to simply change the type of the parameter of g_win32_get_system_data_dirs_for_module() from gconstpointer to void (*f)().

BTW, I wonder if g_win32_get_system_data_dirs_for_module should be considered part of the documented API of GLib or not? (Unfortunately when I added this stuff, I didn't pay as much attention as I should have to such issues.) I think not, so it would be a good idea to add a comment pointing that out, and perhaps add an initial underscore to its name.
Comment 5 Tor Lillqvist 2009-02-12 17:46:01 UTC
Created attachment 128578 [details] [review]
Improved patch
Comment 6 Tor Lillqvist 2009-02-12 17:48:59 UTC
The "unfortunately" is supposed to bind to the "it doesn't work", of course. Sorry for the unclear wording;)
Comment 7 Michael Cronenworth 2009-02-12 17:54:02 UTC
Yes, I should have mentioned my patch just alleviates the warning and wasn't a real fix.

Your patch does the job much better. Thanks!
Comment 8 Tor Lillqvist 2009-02-23 09:53:16 UTC
Fixed in glib-2-18 and trunk.