[Bug c/44555] New: Pointer evalutions, is that expected ?
zilvinas dot valinskas at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Jun 16 09:18:00 GMT 2010
$ 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
More information about the Gcc-bugs
mailing list