" Module_Param* const curr = mp->get_elem(i);\n"
" if (curr->get_type()!=Module_Param::MP_NotUsed) {\n"
" (*this)[i].set_param(*curr);\n"
+ " if (!(*this)[i].is_bound()) {\n"
+ " delete val_ptr->value_elements[i];\n"
+ " val_ptr->value_elements[i] = NULL;\n"
+ " }\n"
" }\n"
" }\n"
" break;\n"
" for (size_t i=0; i<mp->get_size(); ++i) {\n"
" Module_Param* const curr = mp->get_elem(i);\n"
" (*this)[curr->get_id()->get_index()].set_param(*curr);\n"
+ " if (!(*this)[curr->get_id()->get_index()].is_bound()) {\n"
+ " delete val_ptr->value_elements[curr->get_id()->get_index()];\n"
+ " val_ptr->value_elements[curr->get_id()->get_index()] = NULL;\n"
+ " }\n"
" }\n"
" break;\n"
" default:\n"
Module_Param* const curr = mp->get_elem(i);
if (curr->get_type()!=Module_Param::MP_NotUsed) {
get_at(i)->set_param(*curr);
+ if (!get_at(i)->is_bound()) {
+ // use null pointers for unbound elements
+ delete val_ptr->value_elements[i];
+ val_ptr->value_elements[i] = NULL;
+ }
}
}
break;
for (size_t i=0; i<mp->get_size(); ++i) {
Module_Param* const current = mp->get_elem(i);
get_at(current->get_id()->get_index())->set_param(*current);
+ if (!get_at(current->get_id()->get_index())->is_bound()) {
+ // use null pointers for unbound elements
+ delete val_ptr->value_elements[current->get_id()->get_index()];
+ val_ptr->value_elements[current->get_id()->get_index()] = NULL;
+ }
}
break;
default:
if(lengthof(tr_roI5)==3) { setverdict(pass)}else { setverdict(fail) };
}
+// test cases for bug 494614:
+// when initializing a record-of-record element with an empty value ('{}') through module parameters,
+// an actual unbound record element was created, instead of the usual null pointer used for unbound elements;
+// copying this empty record caused a dynamic test case error
+
+modulepar recofOper_myrecof3 recofOper_mymodulepar; // initialized with value list notation
+modulepar recofOper_myrecof3 recofOper_mymodulepar2; // initialized with assignment notation
+
+testcase tc_empty_record_element() runs on recofOper_mycomp {
+ var recofOper_myrecof3 copy := recofOper_mymodulepar;
+ copy[0].x1 := omit; // this is where the record-of is actually copied, and where the DTE occured
+ copy[0].x2 := 1.0;
+ if (copy == { { omit, 1.0 } }) { setverdict(pass); }
+ else { setverdict(fail); }
+}
+
+testcase tc_empty_record_element2() runs on recofOper_mycomp {
+ var recofOper_myrecof3 copy := recofOper_mymodulepar2;
+ copy[0].x1 := omit; // this is where the record-of is actually copied, and where the DTE occured
+ copy[0].x2 := 1.0;
+ if (copy == { { omit, 1.0 } }) { setverdict(pass); }
+ else { setverdict(fail); }
+}
+
control {
const recofOper_trecord cl_temp1:={ x1:=omit, x2:=3.4 }; // constants in the control part
const recofOper_trecof cl_temp2:={ 'AF12'O };
execute(tc_sizeof_lengthof_standard2());
execute(tc_sizeof_lengthof_standard4());
execute(tc_sizeof_lengthof_standard6());
+
+ execute(tc_empty_record_element());
+ execute(tc_empty_record_element2());
}
}
#
###############################################################################
[MODULE_PARAMETERS]
+recofOper_mymodulepar := { {} }
+recofOper_mymodulepar2 := { [0] := {} }
[LOGGING]
Logfile := "recofOper.log"
FileMask := LOG_ALL
#
###############################################################################
[MODULE_PARAMETERS]
+recofOper_mymodulepar := { {} }
+recofOper_mymodulepar2 := { [0] := {} }
[LOGGING]
Logfile := "recofOper.log"
FileMask := LOG_ALL