public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/44555]  New: Pointer evalutions, is that expected ?
@ 2010-06-16  9:18 zilvinas dot valinskas at gmail dot com
  2010-06-16  9:35 ` [Bug c/44555] " schwab at linux-m68k dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: zilvinas dot valinskas at gmail dot com @ 2010-06-16  9:18 UTC (permalink / raw)
  To: gcc-bugs

$ cat ptr.c
#include <stdio.h>

struct a {
        char    b[100];
        int     a;
};

int main(int argc, char *argv[])
{
        struct a *a = NULL;
        void *ptr;

        if (&a->b)
                puts("ok, not null #1");

        if (&a->b == NULL)
                puts("ok, null ? #1");

        ptr = &a->b;
        if (ptr)
                puts("ok, not null #2");

        if (ptr == NULL)
                puts("ok, null ? #2");

        return 0;
}

$ gcc ptr.c -o ptr
$ ./ptr
ok, not null #1
ok, null ? #1
ok, null ? #2

The same results with gcc 4.4.3, gcc 4.5.0 (ubuntu gcc-snapshot package).
Did not try gcc 3.x series.

$ clang ptr.c -o clang-ptr
$ ./clang-ptr 
ok, null ? #1
ok, null ? #2



Tried with gcc 4.4.3:
$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --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 --program-suffix=-4.4 --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc
--disable-werror --with-arch-32=i486 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)

$ gcc-snapshot -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-snapshot/libexec/gcc/x86_64-linux-gnu/4.5.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
20100414-0ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-snapshot/README.Bugs
--enable-languages=c,ada,c++,java,fortran,objc,obj-c++
--prefix=/usr/lib/gcc-snapshot --enable-shared --enable-multiarch
--enable-linker-build-id --with-system-zlib --disable-nls --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin
--enable-gold --with-plugin-ld=ld.gold --disable-browser-plugin
--enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.5-snap/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.5-snap
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.5-snap
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic
--enable-checking=yes --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.5.0 (Ubuntu 20100414-0ubuntu1) 

$ clang -v
clang version 1.1 (branches/release_27)
Target: x86_64-pc-linux-gnu
Thread model: posix


-- 
           Summary: Pointer evalutions, is that expected ?
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: zilvinas dot valinskas at gmail dot com


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


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

end of thread, other threads:[~2010-08-11 13:00 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-16  9:18 [Bug c/44555] New: Pointer evalutions, is that expected ? zilvinas dot valinskas at gmail dot com
2010-06-16  9:35 ` [Bug c/44555] " schwab at linux-m68k dot org
2010-06-16 10:29 ` zilvinas dot valinskas at gmail dot com
2010-06-16 10:44 ` redi at gcc dot gnu dot org
2010-06-16 10:53 ` schwab at linux-m68k dot org
2010-06-16 11:23 ` rguenth at gcc dot gnu dot org
2010-06-16 11:31 ` rguenth at gcc dot gnu dot org
2010-06-16 11:36 ` rguenth at gcc dot gnu dot org
2010-06-16 14:11 ` rguenth at gcc dot gnu dot org
2010-06-16 14:13 ` [Bug c/44555] [4.3/4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
2010-06-24 21:43 ` rguenth at gcc dot gnu dot org
2010-06-25 10:36 ` rguenth at gcc dot gnu dot org
2010-07-27 13:08 ` [Bug c/44555] [4.3/4.4 " rguenth at gcc dot gnu dot org
2010-08-11 13:00 ` [Bug c/44555] [4.3 " rguenth at gcc dot gnu dot org
2010-08-11 13:00 ` rguenth at gcc dot gnu dot 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).