[Bug c/63421] New: GCC generates a very misleading warning when looking at an erroneously-overloaded type
gccbugs at dima dot secretsauce.net
gcc-bugzilla@gcc.gnu.org
Wed Oct 1 00:48:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63421
Bug ID: 63421
Summary: GCC generates a very misleading warning when looking
at an erroneously-overloaded type
Product: gcc
Version: 4.9.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: gccbugs at dima dot secretsauce.net
Hi. I'm running gcc-4.9.1 from Debian/sid. This is built off of r214759. When
building source that had a mistake GCC produced a very misleading warning that
masked the underlying issue. A minimized test case:
typedef struct
{
int x, y, z;
} S;
struct S
{
int x;
};
S s;
void g(struct S *);
void f()
{
g(&s);
}
Here the error is that S is defined both as a struct and a typedef struct. g()
expects a 'struct S *', but I'm giving it a S*. When gcc builds this I see:
dima@shorty:/tmp/recorder$ /usr/bin/gcc-4.9 -g -O0 -Wall -Wextra -std=gnu99 -I.
-c -o dbtest.o dbtest.c
dbtest.c: In function 'f':
dbtest.c:17:5: warning: passing argument 1 of 'g' from incompatible pointer
type
g(&s);
^
dbtest.c:13:6: note: expected 'struct S *' but argument is of type 'struct S *'
void g(struct S *);
^
So it tells me that the function is getting a type mismatch, but it says that
both what it wants and what it got was 'struct S *'. This makes the complaint
look redundant.
More information about the Gcc-bugs
mailing list