This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/18253] New: segfault on dynamic size array init
- From: "atmosfear at users dot sourceforge dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 Oct 2004 17:01:53 -0000
- Subject: [Bug c/18253] New: segfault on dynamic size array init
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
gcc 4.0.0 build 20041024 segfault in the case where a multidimensional array
is inited with variable size dimension based on a variable declared
dynamically earlyier in the same block, eg:
foo(int y){
const int a= y? 1 : 2;
int b[2][a][4];
[...] (code acessing b);
}
The bug happened to me compiling libavcodec/ffv1.c from current-cvs FFmpeg.
The affected code segment looks like this (also see attached preprocessed
source):
---snip---
static void encode_rgb_frame(FFV1Context *s, uint32_t *src, int w, int h, int
stride){
int x, y, p, i;
const int ring_size= s->avctx->context_model ? 3 : 2;
int_fast16_t sample_buffer[3][ring_size][w+6], *sample[3][ring_size];
s->run_index=0;
memset(sample_buffer, 0, sizeof(sample_buffer));
[...more code...]
}
---snip---
The commandline used was:
---snip---
gcc4 -save-temps -I../libvo -I../../libvo -I/usr/X11R6/include -fno-PIC -g -O4
-march=pentium4 -mtune=pentium4 -pipe -ffast-math -fomit-frame-pointer
-D_REENTRANT -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_AV_CONFIG_H
-I.. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -c -o ffv1.o
ffv1.c
---snip---
Resulting output:
---snip---
gcc4: warning: -pipe ignored because -save-temps specified
ffv1.c: In function 'encode_rgb_frame':
ffv1.c:443: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
---snip---
GCC Build Info:
---snip---
Reading specs from /usr/lib/gcc/i686-pc-linux-gnu/4.0.0/specs
Configured with: /var/tmp/portage/gcc-4.0.0/work/gcc-4.0-20041024/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.0
--includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.0.0/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.0
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.0/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.0/info --enable-shared
--host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --with-system-zlib
--enable-languages=c,c++,java --enable-threads=posix --enable-long-long
--disable-checking --enable-cstdio=stdio --enable-clocale=generic
--enable-__cxa_atexit --enable-version-specific-runtime-libs
--with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.0.0/include/g++-v4
--with-local-prefix=/usr/local --disable-werror --enable-shared --enable-nls
--without-included-gettext --x-includes=/usr/X11R6/include
--x-libraries=/usr/X11R6/lib --enable-interpreter --enable-java-awt=xlib
--with-x --disable-multilib
Thread model: posix
gcc version 4.0.0 20041024 (experimental)
---snip---
GCC was build with gentoo gcc-3.4.2-r2 using inofficial gentoo gcc-4.0.0
ebuild from:
http://jaysonking.com/gcc-4.0.0.ebuild
(Now hopefully I can attach the preproessed source, after adding the bug :-)
--
Summary: segfault on dynamic size array init
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: atmosfear at users dot sourceforge dot net
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18253