Bug#299699: dpkg: FTBFS (amd64/gcc-4.0): array type has incomplete element type
Package: dpkg
Severity: normal
Tags: patch
Hello,
the latest version of gcc-4.0 is even more restrictive than the previous
ones. There is a new error message 'array type has incomplete element type'
for constructs like 'extern struct st x[];' when 'struct st' has not
been defined.
When building 'dpkg' on amd64 with gcc-4.0,
I get the following error:
gcc -g -O2 -Wall -Wwrite-strings -Wpointer-arith -Wimplicit -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wbad-function-cast -Wcast-qual -Wcast-align -Winline -Wmissing-noreturn -Wsign-compare -DHAVE_CONFIG_H -D_GNU_SOURCE -DLOCALEDIR=\"/usr/share/locale\" -I../../intl -I../intl -I../../include -I../.. -I../../lib -I../include -I.. -I. -I../../optlib -DUSE_ZLIB -DUSE_BZ2LIB -DCOPYINGFILE=\"/usr/share/doc/dpkg/copyright\" -c ../../lib/dump.c
In file included from ../../lib/dump.c:37:
../../include/parsedump.h:33: error: array type has incomplete element type
../../lib/dump.c: In function 'w_charfield':
../../lib/dump.c:95: warning: cast discards qualifiers from pointer target type
../../lib/dump.c: In function 'w_booleandefno':
../../lib/dump.c:133: warning: cast discards qualifiers from pointer target type
make[3]: *** [dump.o] Error 1
make[3]: Leaving directory `/dpkg-1.10.27/build/lib'
With the attached patch 'dpkg' can be compiled
on amd64 using gcc-4.0.
The attached patch includes the patch from BTS bug #282669. This part has
already been applied to 'experimental' (thanks!).
Regards
Andreas Jochens
diff -urN ../tmp-orig/dpkg-1.10.27/include/parsedump.h ./include/parsedump.h
--- ../tmp-orig/dpkg-1.10.27/include/parsedump.h 2005-02-10 16:24:17.000000000 +0100
+++ ./include/parsedump.h 2005-03-15 22:34:39.544395106 +0100
@@ -30,7 +30,7 @@
const char *canon;
};
-extern const struct fieldinfo fieldinfos[];
+extern const struct fieldinfo *fieldinfos;
extern const struct nickname nicknames[];
extern const int nfields; /* = elements in fieldinfos, including the sentinels */
diff -urN ../tmp-orig/dpkg-1.10.27/lib/parse.c ./lib/parse.c
--- ../tmp-orig/dpkg-1.10.27/lib/parse.c 2005-02-10 16:24:17.000000000 +0100
+++ ./lib/parse.c 2005-03-15 22:34:59.432555170 +0100
@@ -39,7 +39,7 @@
#include <sys/mman.h>
#endif
-const struct fieldinfo fieldinfos[]= {
+const struct fieldinfo *fieldinfos= {
/* NB: capitalisation of these strings is important. */
{ "Package", f_name, w_name },
{ "Essential", f_boolean, w_booleandefno, PKGIFPOFF(essential) },
diff -urN ../tmp-orig/dpkg-1.10.27/lib/mlib.c ./lib/mlib.c
--- ../tmp-orig/dpkg-1.10.27/lib/mlib.c 2005-02-10 16:24:17.000000000 +0100
+++ ./lib/mlib.c 2005-03-15 22:33:48.819188906 +0100
@@ -189,7 +189,7 @@
switch(data->type) {
case BUFFER_WRITE_BUF:
memcpy(data->data.ptr, buf, length);
- (char*)data->data.ptr += length;
+ data->data.ptr = (char*)data->data.ptr + length;
break;
case BUFFER_WRITE_VBUF:
varbufaddbuf((struct varbuf *)data->data.ptr, buf, length);
Reply to: