public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/5459: gcc 3.0.x sometimes prints incorrect warning for function pointer casts
@ 2002-01-23 2:36 espenlaub
0 siblings, 0 replies; 2+ messages in thread
From: espenlaub @ 2002-01-23 2:36 UTC (permalink / raw)
To: gcc-gnats
>Number: 5459
>Category: c
>Synopsis: gcc 3.0.x sometimes prints incorrect warning for function pointer casts
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Jan 23 02:36:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Klaus Espenlaub
>Release: gcc-3.0.3
>Organization:
>Environment:
System: Linux croc 2.4.7-4GB #1 Thu Oct 25 17:53:12 GMT 2001 i686 unknown
Architecture: i686
>Description:
If -Wcast-qual warnings are enabled, then gcc prints a
warning message for the attached code:
gcc3-wbug.c:9: warning: cast discards qualifiers from pointer target type
I looked at the code which prints that, and my guess is that
it doesn't handle the type qualifiers for function types
correctly: const means that a function has no side effects,
and that is always compatible with non-const function types.
Essentially the rule for function type compatibility is
exactly the opposite as for normal pointers.
I came across this issue because gcc-3 seems to be able to
automatically infer the "const" qualifier for functions that
are simple enough. The bug itself may be old, but surfaced
because of the new feature.
>How-To-Repeat:
gcc -Wcast-qual -c gcc3-wbug.c
to compile the attached file (gcc3-wbug.c)
>Fix:
Sorry, no patch. I don't know enough about that part of the
compiler to fix it without breaking other things.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="gcc3-wbug.c"
Content-Disposition: inline; filename="gcc3-wbug.c"
typedef void (*fp)(int);
static void func(void)
{
}
static fp tab[] = {
(fp)func
};
int main(void)
{
(void)tab;
return 0;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: c/5459: gcc 3.0.x sometimes prints incorrect warning for function pointer casts
@ 2002-08-23 13:11 jsm28
0 siblings, 0 replies; 2+ messages in thread
From: jsm28 @ 2002-08-23 13:11 UTC (permalink / raw)
To: espenlaub, gcc-bugs, gcc-prs, nobody
Synopsis: gcc 3.0.x sometimes prints incorrect warning for function pointer casts
State-Changed-From-To: open->closed
State-Changed-By: jsm28
State-Changed-When: Fri Aug 23 13:06:32 2002
State-Changed-Why:
Same bug as c/5330, now fixed.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5459
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-08-23 20:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-23 2:36 c/5459: gcc 3.0.x sometimes prints incorrect warning for function pointer casts espenlaub
2002-08-23 13:11 jsm28
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).