Bug 169991
Summary: | gcc4 problem with glib g_return_val... functions | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Thomas M Steenholdt <tmus> | ||||||
Component: | gcc | Assignee: | Jakub Jelinek <jakub> | ||||||
Status: | CLOSED NOTABUG | QA Contact: | |||||||
Severity: | medium | Docs Contact: | |||||||
Priority: | medium | ||||||||
Version: | 4 | ||||||||
Target Milestone: | --- | ||||||||
Target Release: | --- | ||||||||
Hardware: | i686 | ||||||||
OS: | Linux | ||||||||
Whiteboard: | |||||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||||
Doc Text: | Story Points: | --- | |||||||
Clone Of: | Environment: | ||||||||
Last Closed: | 2005-10-07 10:24:32 UTC | Type: | --- | ||||||
Regression: | --- | Mount Type: | --- | ||||||
Documentation: | --- | CRM: | |||||||
Verified Versions: | Category: | --- | |||||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||
Cloudforms Team: | --- | Target Upstream Version: | |||||||
Embargoed: | |||||||||
Attachments: |
|
Description
Thomas M Steenholdt
2005-10-06 07:32:39 UTC
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! |