diff --git a/core2/Basetype2.cc b/core2/Basetype2.cc index ae2f921994425d1a3e0974e4c121cdc8a2da18d9..231fbee13cc60018a2ccee4da189db6f12beadfb 100644 --- a/core2/Basetype2.cc +++ b/core2/Basetype2.cc @@ -6814,7 +6814,9 @@ int Record_Type::OER_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_bu } if (get_at(p_td.oer->p[i])->is_optional() || is_default_field) { if (!(uc[0] & 1 << (7-act_pos))) { - get_at(p_td.oer->p[i])->set_to_omit(); + if (get_at(p_td.oer->p[i])->is_optional()) { + get_at(p_td.oer->p[i])->set_to_omit(); + } } else { get_at(p_td.oer->p[i])->OER_decode(*fld_descr(p_td.oer->p[i]), p_buf, p_oer); } diff --git a/regression_test/OER/OER.ttcn b/regression_test/OER/OER.ttcn index 9cba67b5d886bbea97edf1735f9febab84e8ac31..531ca79c3fa7efc2b2e2b079032ad4ce4bc8bc00 100644 --- a/regression_test/OER/OER.ttcn +++ b/regression_test/OER/OER.ttcn @@ -3571,6 +3571,20 @@ } setverdict(pass); } + + external function dec_RecWithDefault(in octetstring stream) return RecWithDefault + with { extension "prototype (convert) decode(OER)" } + + // Testing the decoding of a field with a default value (bug 534769) + testcase tc_default() runs on EmptyCT { + var octetstring enc := '000104'O; + var RecWithDefault dec := dec_RecWithDefault(enc); + var RecWithDefault dec_exp := { field2 := 4 }; // the default value is currently not set, the field remains unbound, but there should be no DTE + if (log2str(dec) != log2str(dec_exp)) { + setverdict(fail, "Decoding failed. Got: ", dec, ", expected: ", dec_exp); + } + setverdict(pass); + } control { execute(tc_boolean()); @@ -3593,6 +3607,7 @@ execute(tc_example()); execute(tc_529017()); execute(tc_533061()); + execute(tc_default()); } } diff --git a/regression_test/OER/Types.asn b/regression_test/OER/Types.asn index a15619d2b176d0882cc0cd3a413738b5ffddd6b1..99f60ef03810fb752284a08065dd94f4c2307ae3 100644 --- a/regression_test/OER/Types.asn +++ b/regression_test/OER/Types.asn @@ -543,5 +543,11 @@ Rec533061 ::= SEQUENCE field-ext2 REAL OPTIONAL } +RecWithDefault ::= SEQUENCE +{ + field1 INTEGER DEFAULT 1, + field2 INTEGER +} + END