This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/25326] New: if arr is an array, arr == &arr
- From: "pablo at ipi dot fi" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Dec 2005 11:34:13 -0000
- Subject: [Bug c/25326] New: if arr is an array, arr == &arr
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider following program. I think it shouldn't print anything, but when
compiled with gcc-4.0.? it prints "arr==&arr".
The idea came from comp.lang.c faq question 6.12
(http://www.eskimo.com/~scs/C-faq/q6.12.html)
#include <stdio.h>
int main(int argc,char** argv) {
int arr[1];
int (*bar)[1]=&arr;
if ((void*)arr==(void*)&arr) {
printf("arr==&arr\n");
}
if (bar!=&arr) {
printf("&arr!=&arr\n");
}
return 0;
}
$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr
--with-gxx-include-dir=/usr/include/c++/4.0.2 --enable-shared
--with-system-zlib --libexecdir=/usr/lib --enable-nls
--without-included-gettext --enable-threads=posix --program-suffix=-4.0
--enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre
--enable-mpfr --disable-werror --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)
--
Summary: if arr is an array, arr == &arr
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pablo at ipi dot fi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25326