public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "nordq at ya dot ru" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/44081] Incorrect nonnull assumed in code generation
Date: Thu, 20 Jan 2011 19:06:00 -0000	[thread overview]
Message-ID: <bug-44081-4-NBB5f3U7Dz@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-44081-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #12 from Valeriy <nordq at ya dot ru> 2011-01-20 18:23:29 UTC ---
/*    attr_nn.c    */

#include <stdio.h>

static void attr_nn(int i1, int *i2, int *i3) __attribute__((__nonnull__(2)));
static void attr_nn(int i1, int *i2, int *i3) {
    *i2 = i1;

    if (i3 == 0 || i3 == (int *) 8)  printf("%p  if (0 or 8)\n", i3);
    else                             printf("%p  else       \n", i3);
}

int i2a;

int main(int argc, char *argv[]) {
    attr_nn(1, &i2a, (int *) 0);
    attr_nn(2, &i2a, (int *) 4);
    attr_nn(3, &i2a, (int *) 8);
    return 0;
}




/*
-----------------------------------------------------------------------------

Ubuntu GCC-4.4.5  -  Error


$ gcc -O0 attr_nn.c && ./a.out
$ gcc -O1 attr_nn.c && ./a.out
$ gcc -O3 attr_nn.c && ./a.out

(nil)  if (0 or 8)       <- Ok
0x4  else
0x8  if (0 or 8)

$ gcc -O2 attr_nn.c && ./a.out
$ gcc -Os attr_nn.c && ./a.out

(nil)  else           <- Error
0x4  else
0x8  if (0 or 8)


$ gcc -v
Using built-in specs.
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.4.4-14ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.4 --enable-shared --enable-multiarch
--enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc
--enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic
--enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu
--target=i686-linux-gnu
Thread model: posix
gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5) 

-----------------------------------------------------------------------------

Cygwin GCC-4.3.4  - Ok


$ gcc -O0 attr_nn.c && ./a.exe
$ gcc -O1 attr_nn.c && ./a.exe
$ gcc -O2 attr_nn.c && ./a.exe
$ gcc -O3 attr_nn.c && ./a.exe
$ gcc -Os attr_nn.c && ./a.exe

0x0  if (0 or 8)         <- Ok
0x4  else
0x8  if (0 or 8)

-----------------------------------------------------------------------------

Cygwin GCC-4.5.0  - Error


$ gcc -O0 attr_nn.c && ./a.exe
$ gcc -O1 attr_nn.c && ./a.exe
$ gcc -O3 attr_nn.c && ./a.exe

0x0  if (0 or 8)         <- Ok
0x4  else
0x8  if (0 or 8)

$ gcc -O2 attr_nn.c && ./a.exe
$ gcc -Os attr_nn.c && ./a.exe

0x0  else             <- Error
0x4  else
0x8  if (0 or 8)


$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-cygwin/4.5.0/lto-wrapper.exe
Target: i686-pc-cygwin
Configured with:
/gnu/gcc/releases/respins/4.5.0-1/gcc4-4.5.0-1/src/gcc-4.5.0/configure
--srcdir=/gnu/gcc/releases/respins/4.5.0-1/gcc4-4.5.0-1/src/gcc-4.5.0
--prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin
--libexecdir=/usr/lib --datadir=/usr/share --localstatedir=/var
--sysconfdir=/etc --datarootdir=/usr/share --docdir=/usr/share/doc/gcc4
--datadir=/usr/share --infodir=/usr/share/info --mandir=/usr/share/man -v
--with-gmp=/usr --with-mpfr=/usr --enable-bootstrap
--enable-version-specific-runtime-libs --libexecdir=/usr/lib --enable-static
--enable-shared --enable-shared-libgcc --disable-__cxa_atexit --with-gnu-ld
--with-gnu-as --with-dwarf2 --disable-sjlj-exceptions
--enable-languages=ada,c,c++,fortran,java,lto,objc,obj-c++ --enable-graphite
--enable-lto --enable-java-awt=gtk --disable-symvers --enable-libjava
--program-suffix=-4 --enable-libgomp --enable-libssp --enable-libada
--enable-threads=posix --with-arch=i686 --with-tune=generic
--enable-libgcj-sublibs CC=gcc-4 CXX=g++-4 CC_FOR_TARGET=gcc-4
CXX_FOR_TARGET=g++-4 GNATMAKE_FOR_TARGET=gnatmake GNATBIND_FOR_TARGET=gnatbind
--with-ecj-jar=/usr/share/java/ecj.jar
Thread model: posix
gcc version 4.5.0 (GCC)

-----------------------------------------------------------------------------

MinGW GCC-4.4.3 (Strawberry Perl)  -  Error


>gcc -O0 attr_nn.c && a.exe
>gcc -O1 attr_nn.c && a.exe
>gcc -O3 attr_nn.c && a.exe

00000000  if (0 or 8)    <- Ok
00000004  else
00000008  if (0 or 8)

>gcc -O2 attr_nn.c && a.exe
>gcc -Os attr_nn.c && a.exe

00000000  else           <- Error
00000004  else
00000008  if (0 or 8)


>gcc -v
Using built-in specs.
Target: i686-w64-mingw32
Configured with: ../gcc44-svn/configure --target=i686-w64-mingw32
--host=i686-w64-mingw32 --disable-multilib --disable-nls
--disable-win32-registry --prefix=/mingw32 --with-gmp=/mingw32
-with-mpfr=/mingw32 --enable-languages=c,c++
Thread model: win32
gcc version 4.4.3 (GCC)

-----------------------------------------------------------------------------

MinGW GCC-4.5.0 (20101030)  -  Error


>gcc -O0 attr_nn.c && a.exe
>gcc -O1 attr_nn.c && a.exe
>gcc -O3 attr_nn.c && a.exe

00000000  if (0 or 8)    <- Ok
00000004  else
00000008  if (0 or 8)

>gcc -O2 attr_nn.c && a.exe
>gcc -Os attr_nn.c && a.exe

00000000  else           <- Error
00000004  else
00000008  if (0 or 8)


gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=g:/mingw/bin/../libexec/gcc/mingw32/4.5.0/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.5.0/configure
--enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions
--with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry
--enable-libstdcxx-debug --enable-version-specific-runtime-libs
--disable-werror --build=mingw32 --prefix=/mingw

Thread model: win32
gcc version 4.5.0 (GCC)

-----------------------------------------------------------------------------
*/


  parent reply	other threads:[~2011-01-20 18:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-44081-4@http.gcc.gnu.org/bugzilla/>
2010-12-26 22:57 ` nordq at ya dot ru
2011-01-20 19:06 ` nordq at ya dot ru [this message]
2015-07-26 10:29 ` hv at crypt dot org
2010-05-11 14:41 [Bug c/44081] New: " hv at crypt dot org
2010-05-11 22:59 ` [Bug middle-end/44081] " pinskia at gcc dot gnu dot org
2010-05-12  5:29 ` pmoulder at mail dot csse dot monash dot edu dot au
2010-05-12  6:26 ` jakub at gcc dot gnu dot org
2010-05-12  9:25 ` pmoulder at mail dot csse dot monash dot edu dot au
2010-05-12 10:55 ` hv at crypt dot org
2010-05-12 11:52 ` joseph at codesourcery dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-44081-4-NBB5f3U7Dz@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).