> so accessing the With_Flags array (which is not empty) yields a SEGV > because the base pointer is equal to Last_Unit (i.e. 2). In other words, > the GIMPLE code looks legitimate and the bug is very likely in the stack > slot allocation code (maybe triggered by the newly created zero-sized > arrays).
And this is the real fix. Richard, do you want me to apply (part of it)? * cfgexpand.c (add_stack_var): Assert that the alignment is not zero. * tree-ssa-ccp.c (fold_builtin_alloca_for_var): Force BITS_PER_UNIT alignment at least on the new variable. -- Eric Botcazou
Index: cfgexpand.c =================================================================== --- cfgexpand.c (revision 178422) +++ cfgexpand.c (working copy) @@ -271,6 +271,8 @@ add_stack_var (tree decl) if (v->size == 0) v->size = 1; v->alignb = align_local_variable (SSAVAR (decl)); + /* An alignment of zero can mightily confuse us later. */ + gcc_assert (v->alignb != 0); /* All variables are initially in their own partition. */ v->representative = stack_vars_num; Index: tree-ssa-ccp.c =================================================================== --- tree-ssa-ccp.c (revision 178422) +++ tree-ssa-ccp.c (working copy) @@ -1722,6 +1722,8 @@ fold_builtin_alloca_for_var (gimple stmt elem_type = build_nonstandard_integer_type (BITS_PER_UNIT, 1); n_elem = size * 8 / BITS_PER_UNIT; align = MIN (size * 8, BIGGEST_ALIGNMENT); + if (align < BITS_PER_UNIT) + align = BITS_PER_UNIT; array_type = build_array_type_nelts (elem_type, n_elem); var = create_tmp_var (array_type, NULL); DECL_ALIGN (var) = align;