[notmuch] [PATCH 1/2] * avoid gcc 4.4.1 compiler warnings due to ignored write return values

Jed Brown jed at 59A2.org
Mon Nov 23 08:38:42 PST 2009


On Mon, 23 Nov 2009 18:14:12 +0200, Dirk-Jan Binnema <djcb.bulk at gmail.com> wrote:
> Did you try it with -O2? Without optimizations many of the warnings are not
> issued.

Yes,

$ cat > foo.c
#include <stdlib.h>
#include <unistd.h>
int main()
{
  malloc(5);
  write(2,0,10);
  return 0;
}
$ gcc -static -std=c89 -O0 -Wall -Wextra -pedantic -o foo foo.c
$ objdump -d -M intel foo |grep -A12 '<main>'
00000000004002a4 <main>:
  4002a4:       55                      push   rbp
  4002a5:       48 89 e5                mov    rbp,rsp
  4002a8:       bf 05 00 00 00          mov    edi,0x5
  4002ad:       e8 6e 61 00 00          call   406420 <__libc_malloc>
  4002b2:       ba 0a 00 00 00          mov    edx,0xa
  4002b7:       be 00 00 00 00          mov    esi,0x0
  4002bc:       bf 02 00 00 00          mov    edi,0x2
  4002c1:       e8 ea a0 00 00          call   40a3b0 <__libc_write>
  4002c6:       b8 00 00 00 00          mov    eax,0x0
  4002cb:       c9                      leave  
  4002cc:       c3                      ret    
  4002cd:       90                      nop
$ gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --prefix=/usr --enable-shared --enable-languages=c,c++,fortran,objc,obj-c++,ada --enable-threads=posix --mandir=/usr/share/man --infodir=/usr/share/info --enable-__cxa_atexit --disable-multilib --libdir=/usr/lib --libexecdir=/usr/lib --enable-clocale=gnu --disable-libstdcxx-pch --with-tune=generic
Thread model: posix
gcc version 4.4.2 (GCC)
$ uname -a
Linux kunyang 2.6.31-ARCH #1 SMP PREEMPT Tue Nov 10 19:01:40 CET 2009 x86_64 Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz GenuineIntel GNU/Linux


Seems fishy.

Jed


More information about the notmuch mailing list