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

* [Bug c/60100] warning disappears when preprocessed source is compiled
  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 ` pinskia at gcc dot gnu.org
  2014-02-06 19:41 ` lavr at ncbi dot nlm.nih.gov
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-02-06 19:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60100

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>Also, I'm not sure why there is a bogus warning about linking here (and not when
compiling right from the source file, above).

Because your command line did not actual compile anything.  Use the .i suffix
instead of the .e suffix for preprocessed source and try your commands again.


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

* [Bug c/60100] warning disappears when preprocessed source is compiled
  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
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: lavr at ncbi dot nlm.nih.gov @ 2014-02-06 19:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60100

--- Comment #2 from lavr at ncbi dot nlm.nih.gov ---
> Because your command line did not actual compile anything.

Indeed.  with .i I see the warning again.  But I can't see
any warning if the precompiled file is processed through distcc...


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

* [Bug c/60100] warning disappears when preprocessed source is compiled
  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
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: lavr at ncbi dot nlm.nih.gov @ 2014-02-06 19:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60100

--- Comment #3 from lavr at ncbi dot nlm.nih.gov ---
Ok, sorry and let me start again.  My original mockup case wasn't good enough.

So attached is the real (preprocessed) code that fails to produce a warning
(yet when compiled from the .c form, the warning is there).

This completes w/o warnings:

> gcc  -E -std=gnu11 -fgnu89-inline -c  -Wall -Wno-format-y2k   -fPIC  -gdwarf-3     -D_DEBUG -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64   -DNCBI_WITHOUT_MT -I/home/lavr/cxx/GCC-Debug64/inc -I/home/lavr/cxx/include  /home/lavr/cxx/src/connect/ncbi_socket.c -o ncbi_socket.i
> gcc -std=gnu11 -fgnu89-inline -c  -Wall -Wno-format-y2k   -fPIC  -gdwarf-3     -D_DEBUG -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 ncbi_socket.i -o ncbi_socket.o

This produces a warning (as it should):

 gcc -c -std=gnu11 -fgnu89-inline -c  -Wall -Wno-format-y2k   -fPIC  -gdwarf-3 
   -D_DEBUG -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  
-DNCBI_WITHOUT_MT -I/home/lavr/cxx/GCC-Debug64/inc -I/home/lavr/cxx/include 
/home/lavr/cxx/src/connect/ncbi_socket.c -o ncbi_socket.o
/home/lavr/cxx/src/connect/ncbi_socket.c: In function 's_WritePending':
/home/lavr/cxx/src/connect/ncbi_socket.c:3447:33: warning: passing argument 3
of 'BUF_PeekAtCB' from incompatible pointer type [enabled by default]
                                 x_WriteBuf, &ctx, sock->w_len);
                                 ^
In file included from /home/lavr/cxx/src/connect/ncbi_socketp.h:44:0,
                 from /home/lavr/cxx/src/connect/ncbi_connssl.h:37,
                 from /home/lavr/cxx/src/connect/ncbi_socket.c:76:
/home/lavr/cxx/include/connect/ncbi_buffer.h:180:36: note: expected 'size_t
(*)(void *, const void *, size_t)' but argument is of type 'size_t (*)(void *,
const void *, size_t,  int)'
 extern NCBI_XCONNECT_EXPORT size_t BUF_PeekAtCB


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

* [Bug c/60100] warning disappears when preprocessed source is compiled
  2014-02-06 19:32 [Bug c/60100] New: warning disappears when preprocessed source is compiled lavr at ncbi dot nlm.nih.gov
                   ` (2 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: lavr at ncbi dot nlm.nih.gov @ 2014-02-06 19:51 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60100

--- Comment #4 from lavr at ncbi dot nlm.nih.gov ---
Created attachment 32072
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32072&action=edit
Preprocessed C source that fails to produce a warning when compiled


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

* [Bug c/60100] warning disappears when preprocessed source is compiled
  2014-02-06 19:32 [Bug c/60100] New: warning disappears when preprocessed source is compiled lavr at ncbi dot nlm.nih.gov
                   ` (3 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-03-24 10:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60100

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2014-03-24
                 CC|                            |mpolacek at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
OK, you attached the .i file that when compiled issues no warning.  But I don't
see the .c file (with its headers) attached, so can't try it out.

Seems related to PR59749.


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

* [Bug c/60100] warning disappears when preprocessed source is compiled
  2014-02-06 19:32 [Bug c/60100] New: warning disappears when preprocessed source is compiled lavr at ncbi dot nlm.nih.gov
                   ` (4 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: schwab@linux-m68k.org @ 2014-03-24 13:44 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60100

--- Comment #7 from Andreas Schwab <schwab@linux-m68k.org> ---
# 3416 "/home/lavr/cxx/src/connect/ncbi_socket.c" 3 4

The file is marked as system header, perhaps because the expansion on this line
came from a system header?  (looks like assert(...))  Note that there are
several occurences of # 3416, some as system headers, some not, but it's the
last one that matters for line 3447.


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

* [Bug c/60100] warning disappears when preprocessed source is compiled
  2014-02-06 19:32 [Bug c/60100] New: warning disappears when preprocessed source is compiled lavr at ncbi dot nlm.nih.gov
                   ` (5 preceding siblings ...)
  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
  8 siblings, 0 replies; 10+ messages in thread
From: lavr at ncbi dot nlm.nih.gov @ 2014-03-24 15:56 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60100

--- Comment #8 from lavr at ncbi dot nlm.nih.gov ---
This is the code from the original .c file that fails to post a warning.

    sock->w_len -= BUF_PeekAtCB(sock->w_buf,
                                BUF_Size(sock->w_buf) - sock->w_len,
                                x_WriteBuf, &ctx, sock->w_len);

It is not changed in any way during pre-processing.

An assert() comes right after it.  x_WriteBuf is a function (defined
just prior to the function where it is used) that had a wrong prototype
versus what a header defining BUF_PeekAtCB() declared.

What constitutes a system header?  Because a file that defines BUF_PeekAtCB()
is referenced via angle brackets (versus quotes) in the #include directive.
A path for gcc is provided with the -I option.

Finally, if gcc compiling the original code .c manages to post a warning,
it certainly somehow knows that no system headers are involved in this
particular case.


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

* [Bug c/60100] warning disappears when preprocessed source is compiled
  2014-02-06 19:32 [Bug c/60100] New: warning disappears when preprocessed source is compiled lavr at ncbi dot nlm.nih.gov
                   ` (6 preceding siblings ...)
  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
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-04-11 10:01 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60100

--- Comment #9 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I guess also a dup of PR57201.


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

* [Bug c/60100] warning disappears when preprocessed source is compiled
  2014-02-06 19:32 [Bug c/60100] New: warning disappears when preprocessed source is compiled lavr at ncbi dot nlm.nih.gov
                   ` (7 preceding siblings ...)
  2014-04-11 10:01 ` mpolacek at gcc dot gnu.org
@ 2014-09-19 19:48 ` schwab@linux-m68k.org
  8 siblings, 0 replies; 10+ messages in thread
From: schwab@linux-m68k.org @ 2014-09-19 19:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60100

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gccbugs at dima dot secretsauce.ne
                   |                            |t

--- Comment #11 from Andreas Schwab <schwab@linux-m68k.org> ---
*** Bug 63178 has been marked as a duplicate of this bug. ***


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