From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b4) Gecko/20051006 Fedora/1.5b1-0.fc4 Firefox/1.4 Description of problem: The g_return_val_if_fail macro from glib-2.0 fails with gcc4. The macro wraps the g_return_if_fail_warning function, but building with gcc4 and "-Wall -Werror -ansi" makes it spew the following error at every call to g_return_val_if_fail warning: passing argument 2 of 'g_return_if_fail_warning' discards qualifiers from pointer target type i'm not calling g_return_if_fail_warning directly from anywhere within my code. if i do the exact same build with gcc32, I have no problems... Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1. get meanwhile (or other software that uses g_return_val_if_fail) from meanwhile.sf.net 2. untar and CFLAGS="-Wall -Werror -ansi" ./configure 3. make and watch the errors Actual Results: lots of "warning: passing argument 2 of 'g_return_if_fail_warning' discards qualifiers from pointer target type" Expected Results: clean compile! Additional info: Trying instead : CC=gcc32 CFLAGS="-Wall -Werror -ansi" ./configure make All is good! It looks like it may have something to do with gcc's __PRETTY_FUNCTION__ thing?
Please provide either preprocessed source of the file on which you get the warning, or create a minimal self-contained testcase. I haven't seen any problem on the short testcase I tried, so likely the program you're trying to build is doing something wrong. g_return_if_fail_warning has 3 const char * arguments, so if you pass say a char * argument to it, the warning is in order. But, __PRETTY_FUNCTION__ unless redefined in the source is const char *.
Created attachment 119688 [details] testcase created from trimmed down gaim plugin This is the easiest way (for me) to try to illustrate the problem for you. untar, then run CFLAGS="-Wall -Werror -ansi" ./autogen.sh followed by make... assuming you're on FC4 or likely any gcc4 based platform, you should get the error i'm talking about. then try make clean, CC=gcc32 CFLAGS="-Wall -Werror -ansi" ./autogen.sh followed by make and the error is gone. I have to admit that i'm new to gnu make and all the stuff that goes on in here, so i hope that's not what screws things up!
I can't reproduce this. Though I can't understand how is it easiest for you to create such trimmed down testcase as opposed simply noting all command line options used to build that file, replacing -c on that command line with -E and if -o is missing, adding -o test.i and attaching test.i here, plus writing what options were used.
That's because i'm a moron! Here's a better way to reproduce that involves much less work and much fewer variable/unknown factors. gcc -Dconst= -I. -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wall -Werror -ansi test.c I'll attach the test.c file in 30 secs... Also, in cleaning up this test to be a lot better suited for tracking down problems, I discovered that the problem goes away when taking -Dconst= out of the command. I hope this works for you! I have tried this with several FC4 installations all on latest errata level and they all do the same thing!
Created attachment 119701 [details] tiny g_return_val_if_fail testcase
Exact output is: [tmus@home testcase]$ gcc -Dconst= -I. -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wall -Werror -ansi test.c cc1: warnings being treated as errors test.c: In function âtestâ: test.c:4: warning: passing argument 2 of âg_return_if_fail_warningâ discards qualifiers from pointer target type
If you use -Dconst=, then you certainly get what you are asking for. There is no bug on the GCC side. __PRETTY_FUNCTION__ is const char *, no matter if you redefine const keyword using a macro or not, so the compiler has all rights to warn about it being assigned to a char * argument (as g_return_if_fail_warning uses const in the prototype and you changed the prototype with -Dconst=).
Right, that's what I thought - I'm no compiler expert even by a longshot. But try to do the same thing with gcc32 - No warning! Which indicates to me that something is rotten! It may be with gcc32 though??
Anyways - I should have trimmed it all the way down to this from the beginning. I don't really need the -Dconst= and everyhing is working now!