This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/21536] [3.4/4.0/4.1 Regression] C99 array of variable length use causes segmentation fault


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]