diff --git a/compiler2/record_of.c b/compiler2/record_of.c
index 1825ce45c7d386b20ba9dda07a84e14de1fe68ed..b4544edcb7efed1d8126659f58e312d323e2aa01 100644
--- a/compiler2/record_of.c
+++ b/compiler2/record_of.c
@@ -986,13 +986,13 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
     "    }\n"
     "    if(a==0) val_ptr->n_elements=0;\n"
     "  } else {\n"
-    "    int a=start_field;\n"
     "    if(limit==0){\n"
     "      if(!first_call) return -1;\n"
     "      val_ptr->n_elements=0;\n"
     "      return decoded_length+p_buf.increase_pos_padd(p_td.raw->padding)"
     "+prepaddlength;\n"
     "    }\n"
+    "    int a=start_field;\n"
     "    while(limit>0){\n"
     "      start_of_field=p_buf.get_pos_bit();\n"
     "      decoded_field_length=(*this)[a].RAW_decode(*p_td.oftype_descr,p_buf,limit,"