Date: Wed, 14 Sep 94 22:21 PDT From: jdp AT polstra DOT com (John Polstra) To: djgpp AT polstra DOT com Subject: Solved: GCC Segmentation Violation after 1st Undeclared Variable As has been reported here earlier by somebody else, GCC in DJGPP112 quits with a segmentation violation shortly after reporting the first undeclared variable in a C++ program. I tracked down the cause of the problem this evening, with the help of the new GDB in the DJGPP112 release. (Thanks, DJ!) The problem turns out to be a bug in GCC and is not specific to DJGPP. It just happens to cause a segmentation violation under DJGPP. Here is a patch: [Beginning of patch] *** src/gcc-260/cp/typeck.c- Sat Jul 9 00:12:25 1994 --- src/gcc-260/cp/typeck.c Wed Sep 14 22:04:28 1994 *************** *** 77,83 **** { tree type = TREE_TYPE (value); ! /* First, detect a valid value with a complete type. */ if (TYPE_SIZE (type) != 0 && type != void_type_node && ! (TYPE_LANG_SPECIFIC (type) --- 77,87 ---- { tree type = TREE_TYPE (value); ! /* If the value is the error mark node, leave it alone. */ ! if (value == error_mark_node) ! return value; ! ! /* Detect a valid value with a complete type. */ if (TYPE_SIZE (type) != 0 && type != void_type_node && ! (TYPE_LANG_SPECIFIC (type) [End of patch] The macro TYPE_LANG_SPECIFIC was referencing a tree node field that does not exist (is not allocated) in the special error_mark_node. The error_mark_node gets put into the tree when the undeclared variable is detected. I will report the bug and the patch to the GNU folks. John Polstra jdp AT polstra DOT com John D. Polstra & Co., Inc. Phone (206) 932-6482 Seattle, Washington USA Fax (206) 935-1262 "Self-knowledge is always bad news." -- John Barth