This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/21536] [3.4/4.0/4.1 Regression] C99 array of variable length use causes segmentation fault
- From: "jakub at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 May 2005 17:14:29 -0000
- Subject: [Bug c/21536] [3.4/4.0/4.1 Regression] C99 array of variable length use causes segmentation fault
- References: <20050512180113.21536.shane256@hotmail.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From jakub at gcc dot gnu dot org 2005-05-27 17:14 -------
I can't reproduce the segfault, but that's only because the problem manifests
as use of uninitialized variable.
/* PR c/21536 */
/* { dg-do compile } */
/* { dg-options "-O2 -Wuninitialized" } */
typedef __SIZE_TYPE__ size_t;
extern void *malloc (size_t);
void
foo (int x, int y)
{
void *d = malloc (10 * 10 * sizeof (double));
double (*e)[x][y] = d;
if (x > 8)
(*e)[x - 2][y - 2] = 0.0;
else
(*e)[x - 1][y - 1] = 1.0;
}
int
main ()
{
foo (10, 10);
return 0;
}
reproduces the problem reliably (by checking if it issued a bogus warning:
warning: '.0' is used uninitialized in this function).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21536