THRIFT-808. Segfault when constant declaration references a struct field that doesn't exist

This patch causes a useful error to be printed instead of an anonymous segfault.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@957270 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/parse/t_scope.h b/compiler/cpp/src/parse/t_scope.h
index d3f9d26..585b910 100644
--- a/compiler/cpp/src/parse/t_scope.h
+++ b/compiler/cpp/src/parse/t_scope.h
@@ -96,6 +96,9 @@
       std::map<t_const_value*, t_const_value*>::const_iterator v_iter;
       for (v_iter = map.begin(); v_iter != map.end(); ++v_iter) {
         t_field* field = tstruct->get_field_by_name(v_iter->first->get_string());
+        if (field == NULL) {
+          throw "No field named \"" + v_iter->first->get_string() + "\" was found in struct of type \"" + tstruct->get_name() + "\"";
+        }
         resolve_const_value(v_iter->second, field->get_type());
       }
     } else if (const_val->get_type() == t_const_value::CV_IDENTIFIER) {