This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Prevent seg fault on buggy input
- To: gcc-patches at gcc dot gnu dot org
- Subject: Prevent seg fault on buggy input
- From: Nick Clifton <nickc at cygnus dot com>
- Date: Wed, 26 Apr 2000 12:20:02 -0700
Hi Guys,
Given the following, buggy, C program as input, gcc will currently
generate a seg fault after emitting a few error messages:
#define page1 0x100000
main() {
unsigned long ttb_base = ((unsigned long)&page1)+RAM);
The patch below fixes this by making the initialisation parsing code
check for errors before attempting to compare types.
Is this patch OK to apply ?
Cheers
Nick
2000-04-26 Nick Clifton <nickc@cygnus.com>
* c-typeck.c (digest_init): Check for errors before comparing
types.
Index: gcc/c-typeck.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-typeck.c,v
retrieving revision 1.63
diff -p -r1.63 c-typeck.c
*** c-typeck.c 2000/04/10 11:59:46 1.63
--- c-typeck.c 2000/04/26 19:19:11
*************** digest_init (type, init, require_constan
*** 4588,4594 ****
/* Any type can be initialized
from an expression of the same type, optionally with braces. */
! if (inside_init && TREE_TYPE (inside_init) != 0
&& (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
TYPE_MAIN_VARIANT (type))
|| (code == ARRAY_TYPE
--- 4588,4596 ----
/* Any type can be initialized
from an expression of the same type, optionally with braces. */
! if (inside_init
! && TREE_CODE (inside_init) != ERROR_MARK
! && TREE_TYPE (inside_init) != 0
&& (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
TYPE_MAIN_VARIANT (type))
|| (code == ARRAY_TYPE