This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
CVS gcc/tree.c: still broken for zero length arrays
- To: <gcc-bugs at gcc dot gnu dot org>
- Subject: CVS gcc/tree.c: still broken for zero length arrays
- From: Craig Newell <craign at ieee dot org>
- Date: Thu, 23 Nov 2000 21:48:29 -0500 (EST)
Hi All,
Just a short note to say that even after Richard Henderson's recent
attempt to fix the breakage in gcc/tree.c caused by Richard Kenner's
change to gcc/tree.c back in Oct. At least the compiler no longer
generates incorrect code but it currently dereferences NULL which is also
not too healthy.
A simple testcase to show the current crash:
--- bug.i ------------------
typedef union {
int *a;
int b[0];
} u;
----------------------------
When run under GDB it produces the following results:
----------------------------
(gdb) run
Starting program: /opt/arm/lib/gcc-lib/arm-elf/2.97/cc1 bug.i
Program received signal SIGSEGV, Segmentation fault.
0x80a39cd in size_binop (code=MAX_EXPR, arg0=0x4017bc40, arg1=0x0)
at /home/craign/egcs/egcs/gcc/fold-const.c:1911
1911 if (TREE_CODE (type) != INTEGER_TYPE || ! TYPE_IS_SIZETYPE
(type)
(gdb) bt
#0 0x80a39cd in size_binop (code=MAX_EXPR, arg0=0x4017bc40, arg1=0x0)
at /home/craign/egcs/egcs/gcc/fold-const.c:1911
#1 0x809e381 in place_union_field (rli=0x82d30f0, field=0x40188a80)
at /home/craign/egcs/egcs/gcc/stor-layout.c:614
#2 0x80a0746 in layout_type (type=0x40188b00) at
/home/craign/egcs/egcs/gcc/stor-layout.c:1443
#3 0x805bc1f in finish_struct (t=0x40188b00, fieldlist=0x40188900,
attributes=0x0)
at /home/craign/egcs/egcs/gcc/c-decl.c:5588
#4 0x804b9bd in yyparse_1 () at /home/craign/egcs/egcs/gcc/c-parse.y:1255
#5 0x808abb3 in compile_file (name=0x82cfa20 "bug.i") at
/home/craign/egcs/egcs/gcc/toplev.c:2363
#6 0x808e353 in main (argc=2, argv=0xbffff844) at
/home/craign/egcs/egcs/gcc/toplev.c:4844
#7 0x4003da7c in __libc_start_main (main=0x808dc80 <main>, argc=2,
ubp_av=0xbffff844,
init=0x8049070 <_init>, fini=0x821e07c <_fini>, rtld_fini=0x4000d684
<_dl_fini>,
stack_end=0xbffff83c) at ../sysdeps/generic/libc-start.c:111
(gdb)
----------------------------
Just for reference: Richard Henderson's attempt to fix gcc/tree.c:
----------------------------
revision 1.174
date: 2000/11/19 08:36:18; author: rth; state: Exp; lines: +3 -18
* c-decl.c (grokdeclarator): Special case the creation of an
index for a zero-length array.
* tree.c (build_index_type): Revert Oct 20 change.
----------------------------
And the original breakage of gcc/tree.c:
----------------------------
revision 1.165
date: 2000/10/20 20:57:21; author: kenner; state: Exp; lines: +44 -15
* expr.c (expand_expr, case SAVE_EXPR): Set RTX_UNCHANGING_P on
returned MEM.
(expand_expr_unaligned, case ARRAY_REF): Check that index is
a constant before comparing it; use tree_low_cst.
* tree.c (save_expr): Set TREE_READONLY.
(substitute_expr): Return inside of NON_LVALUE_EXPR.
(build, build1): Set TREE_READONLY if all operands are.
(build_index_type): If upper bound is a negative number, lower
bound is zero and sizetype is unsigned, use upper bound of one and
lower of zero.
----------------------------
Thanks,
CraigN
--
Craig Newell email: CraigN@ieee.org
Free Spirit icbm: N 42°38'47" W 71°18'19"