public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/60100] New: warning disappears when preprocessed source is compiled
@ 2014-02-06 19:32 lavr at ncbi dot nlm.nih.gov
  2014-02-06 19:34 ` [Bug c/60100] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: lavr at ncbi dot nlm.nih.gov @ 2014-02-06 19:32 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-09-19 19:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-06 19:32 [Bug c/60100] New: warning disappears when preprocessed source is compiled lavr at ncbi dot nlm.nih.gov
2014-02-06 19:34 ` [Bug c/60100] " pinskia at gcc dot gnu.org
2014-02-06 19:41 ` lavr at ncbi dot nlm.nih.gov
2014-02-06 19:50 ` lavr at ncbi dot nlm.nih.gov
2014-02-06 19:51 ` lavr at ncbi dot nlm.nih.gov
2014-03-24 10:47 ` mpolacek at gcc dot gnu.org
2014-03-24 13:44 ` schwab@linux-m68k.org
2014-03-24 15:56 ` lavr at ncbi dot nlm.nih.gov
2014-04-11 10:01 ` mpolacek at gcc dot gnu.org
2014-09-19 19:48 ` schwab@linux-m68k.org

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).