public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "zilvinas dot valinskas at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/44555]  New: Pointer evalutions, is that expected ?
Date: Wed, 16 Jun 2010 09:18:00 -0000	[thread overview]
Message-ID: <bug-44555-19333@http.gcc.gnu.org/bugzilla/> (raw)

$ 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


             reply	other threads:[~2010-06-16  9:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-16  9:18 zilvinas dot valinskas at gmail dot com [this message]
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

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-44555-19333@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).