Bug#318612: gcc-4.0: gcc 4.0 refuses to compile void foo(struct bar[]); 3.4 is OK
Package: gcc-4.0
Version: 4.0.1-2
Severity: important
gcc 4.0 fails to compile the following 3 line sample:
struct bar;
void baz(struct bar*);
void foo(struct bar[]);
gcc 3.4 and older do not complain.
The issue is that gcc-3.4 and older realize that [] in a parameter is the
same as * and accepts the incomplete structure type, gcc 4.0 does not.
This causes the Linux kernel, version 2.6.11 to miscompile i2c.h preventing
kernel recompile (Someone else has opened a bug against the kernel, but I
still see this as a general gcc bug).
Transcript:
lindev@src.12:~/x1 0$ gcc-4.0 --verbose -Wall -c test1.c
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr --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 --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.1 (Debian 4.0.1-2)
/usr/lib/gcc/i486-linux-gnu/4.0.1/cc1 -quiet -v test1.c -quiet -dumpbase test1.c -mtune=i486 -auxbase test1 -Wall -version -o /tmp/cc7VWjlw.s
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/i486-linux-gnu/4.0.1/include
/usr/include
End of search list.
GNU C version 4.0.1 (Debian 4.0.1-2) (i486-linux-gnu)
compiled by GNU C version 4.0.1 (Debian 4.0.1-2).
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129254
test1.c:3: error: array type has incomplete element type
lindev@src.12:~/x1 0$ gcc-3.4 --verbose -Wall -c test1.c
Reading specs from /usr/lib/gcc/i486-linux-gnu/3.4.5/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --program-suffix=-3.4 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk --disable-werror i486-linux-gnu
Thread model: posix
gcc version 3.4.5 20050706 (prerelease) (Debian 3.4.4-5)
/usr/lib/gcc/i486-linux-gnu/3.4.5/cc1 -quiet -v test1.c -quiet -dumpbase test1.c -mtune=i486 -auxbase test1 -Wall -version -o /tmp/cctzdJGc.s
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/i486-linux-gnu/3.4.5/../../../../i486-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/i486-linux-gnu/3.4.5/include
/usr/include
End of search list.
GNU C version 3.4.5 20050706 (prerelease) (Debian 3.4.4-5) (i486-linux-gnu)
compiled by GNU C version 3.4.5 20050706 (prerelease) (Debian 3.4.4-5).
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129254
as -V -Qy --32 -o test1.o /tmp/cctzdJGc.s
GNU assembler version 2.16.1 (i486-linux-gnu) using BFD version 2.16.1 Debian GNU/Linux
-- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.11jbj3.2.10
Locale: LANG=en_DK.UTF-8, LC_CTYPE=en_DK.UTF-8 (charmap=UTF-8)
Versions of packages gcc-4.0 depends on:
ii binutils 2.16.1-2 The GNU assembler, linker and bina
ii cpp-4.0 4.0.1-2 The GNU C preprocessor
ii gcc-4.0-base 4.0.1-2 The GNU Compiler Collection (base
ii libc6 2.3.2.ds1-22 GNU C Library: Shared libraries an
ii libgcc1 1:4.0.1-2 GCC support library
Versions of packages gcc-4.0 recommends:
ii libc6-dev 2.3.2.ds1-22 GNU C Library: Development Librari
ii libmudflap0-dev 4.0.1-2 GCC mudflap support libraries (dev
-- no debconf information
Reply to: