[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#358755: g++-4.0: G++ drops const int arrays



Package: g++-4.0
Version: 4.0.3-1
Severity: normal

Hi,

G++ seems to drop const int arrays, while gcc compiles them correctly.

See the following example of the two attached files:

gcc -Wall -c gen_array.c
gcc -Wall -o gen_array gen_array.o
./gen_array > array.cc
g++ -Wall -o array.cc.o -c array.cc
ls -l array.cc.o
-rw-r--r--  1 schabi schabi 638 Mar 24 11:19 array.cc.o
./gen_array > array.c
gcc -Wall -o array.c.o -c array.c
ls -l array.c.o
-rw-r--r--  1 schabi schabi 4735 Mar 24 11:19 array.c.o


array_cc.o should also be more than 4000 bytes large, because the array
contents itsself are 4000 bytes. GCC seems to translate it correctly.

Thanks,
Markus
-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16-fire
Locale: LANG=C, LC_CTYPE=de_DE@euro (charmap=ISO-8859-15)

Versions of packages g++-4.0 depends on:
ii  gcc-4.0                       4.0.3-1    The GNU C compiler
ii  gcc-4.0-base                  4.0.3-1    The GNU Compiler Collection (base 
ii  libc6                         2.3.6-3    GNU C Library: Shared libraries an
ii  libstdc++6-4.0-dev            4.0.3-1    The GNU Standard C++ Library v3 (d

g++-4.0 recommends no packages.

-- no debconf information
.PHONY: all clean

CXX=g++ -Wall
CC=gcc -Wall

all: array.cc.o array.c.o

array.cc.o : array.cc
	${CXX} -o $@ -c $^
	ls -l $@

array.c.o : array.c
	${CC} -o $@ -c $^
	ls -l $@

array.cc : gen_array
	./gen_array > $@

array.c : gen_array
	./gen_array > $@

gen_array : gen_array.o
	${CC} -o $@ $^

gen_array.o : gen_array.c
	${CC} -c $^

clean:
	rm -vf *.o array.*c gen_array
// generates an C/C++ array file.

#include <stdio.h>

int main()
{
	int i;
	printf("const int Table[] = {\n");
	for(i = 0; i<1000; ++i)
	{
		printf("\t%d,\n", i);
	}
	printf("\t};\n");
	return 0;
}

Reply to: