# HG changeset patch
# User Mario de Sousa <msousa@fe.up.pt>
# Date 1334603638 -3600
# Node ID fdef852a6565d51631e84e10e4f33ff31bd0f694
# Parent  c2880eba49a1286a1134521301fdca368514af06
Fix bug when handling code with data type errors.

diff -r c2880eba49a1 -r fdef852a6565 stage3/narrow_candidate_datatypes.cc
--- a/stage3/narrow_candidate_datatypes.cc	Mon Apr 16 15:40:12 2012 +0100
+++ b/stage3/narrow_candidate_datatypes.cc	Mon Apr 16 20:13:58 2012 +0100
@@ -96,6 +96,12 @@
 
 
 bool narrow_candidate_datatypes_c::is_widening_compatible(const struct widen_entry widen_table[], symbol_c *left_type, symbol_c *right_type, symbol_c *result_type, bool *deprecated_status) {
+	/* NOTE: According to our algorithm, left_type and right_type should never by NULL (if they are, we have an internal compiler error!
+	 *       However, result_type may be NULL if the code has a data type semantic error!
+	 */
+	if ((NULL == left_type) || (NULL == right_type) || (NULL == result_type))
+		return false;
+
 	for (int k = 0; NULL != widen_table[k].left;  k++) {
 		if        ((typeid(*left_type)   == typeid(*widen_table[k].left))
 		        && (typeid(*right_type)  == typeid(*widen_table[k].right))