THRIFT-3751 Compiler allows field ids that are too large for generated code
Client: Compiler (General)
Patch: Jens Geyer
This closes #964
diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy
index dee4cb9..292670d 100644
--- a/compiler/cpp/src/thrifty.yy
+++ b/compiler/cpp/src/thrifty.yy
@@ -913,11 +913,19 @@
$$.value = static_cast<int32_t>($1);
$$.auto_assigned = false;
}
+ if( (SHRT_MIN > $$.value) || ($$.value > SHRT_MAX)) {
+ pwarning(1, "Field key (%d) exceeds allowed range (%d..%d).\n",
+ $$.value, SHRT_MIN, SHRT_MAX);
+ }
}
|
{
$$.value = y_field_val--;
$$.auto_assigned = true;
+ if( (SHRT_MIN > $$.value) || ($$.value > SHRT_MAX)) {
+ pwarning(1, "Field key (%d) exceeds allowed range (%d..%d).\n",
+ $$.value, SHRT_MIN, SHRT_MAX);
+ }
}
FieldReference: