This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/18411] New: Warning not legitimate
- From: "manus at eiffel dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Nov 2004 23:23:43 -0000
- Subject: [Bug c/18411] New: Warning not legitimate
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I'm getting the following compilation warning output:
gcc -c a.c -save-temps
a.c: In function `g':
a.c:8: warning: function called through a non-compatible type
a.c:8: note: if this code is reached, the program will abort
while compiling the following code (content of a.i):
# 1 "a.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "a.c"
extern void f();
void g(char a) {
void * fnptr = f;
((void (*) (char)) fnptr) (a);
((void (*) (char)) f)(a);
}
It reports a warning when using `f' but not when using `fnptr'. This is rather
strange and not expected.
Why is it so?
gcc --version is:
gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
and was compiled on a AMD64 machine using Linux Fedora Core 3 for x86_64:
uname -a
Linux madrid.ise 2.6.9-1.667 #1 Tue Nov 2 14:50:10 EST 2004 x86_64 x86_64
x86_64 GNU/Linux
Thanks,
Manu
--
Summary: Warning not legitimate
Product: gcc
Version: 3.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: manus at eiffel dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18411