This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/60100] New: warning disappears when preprocessed source is compiled
- From: "lavr at ncbi dot nlm.nih.gov" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 06 Feb 2014 19:32:30 +0000
- Subject: [Bug c/60100] New: warning disappears when preprocessed source is compiled
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60100
Bug ID: 60100
Summary: warning disappears when preprocessed source is
compiled
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: lavr at ncbi dot nlm.nih.gov
Created attachment 32070
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32070&action=edit
GCC specs are attached
Hello,
When compiling the attached C code with GCC 4.8.1, I see a warning (which is
correct) that the callback signature mismatches what's expected in the argument
of BUF_PeekAtCB() call. If however, the source is first preprocessed then
compiled, there is no warning! Since distcc uses precompiled source, the
disappearing warning is a bad thing because it hides potential (and real, such
as this case) bugs.
$ cat qq.h
#include <stddef.h>
typedef struct SBUF* BUF;
extern size_t BUF_PeekAtCB
(BUF buf,
size_t pos,
size_t (*callback)(void* cbdata, const void* buf, size_t size),
void* cbdata,
size_t size
);
$ cat qq.c
#include <stdio.h>
#include "qq.h"
size_t cb(void* a, void* b, size_t c, int d)
{
return c;
}
int main()
{
BUF b = 0;
size_t n = BUF_PeekAtCB(b, 0, cb, 0, 512);
printf("%u\n", (unsigned int) n);
return 0;
}
$ gcc -Wall -c qq.c -o qq.o
qq.c: In function 'main':
qq.c:14:5: warning: passing argument 3 of 'BUF_PeekAtCB' from incompatible
pointer type [enabled by default]
size_t n = BUF_PeekAtCB(b, 0, cb, 0, 512);
^
In file included from qq.c:2:0:
qq.h:7:15: note: expected 'size_t (*)(void *, const void *, size_t)' but
argument is of type 'size_t (*)(void *, void *, size_t, int)'
extern size_t BUF_PeekAtCB
^
$ gcc -Wall -E qq.c -o qq.e
$ gcc -Wall -c qq.e -o qq.o
gcc: warning: qq.e: linker input file unused because linking not done
Also, I'm not sure why there is a bogus warning about linking here (and not
when
compiling right from the source file, above).
Any insight that you may have provide will be highly appreciated.
Thanks,
Anton Lavrentiev