diff --git a/compiler2/Type_codegen.cc b/compiler2/Type_codegen.cc
index 1f277cdb87c9915aa3c100ab4fef03cc5f2f4360..a726a88930de50ba8fb37b63648ba9c3df002563 100644
--- a/compiler2/Type_codegen.cc
+++ b/compiler2/Type_codegen.cc
@@ -722,8 +722,16 @@ void Type::generate_code_rawdescriptor(output_struct *target)
   else str = mputstr(str, "SG_NO,");
   if (rawattrib->byteorder == XDEFLAST) str = mputstr(str, "ORDER_MSB,");
   else str = mputstr(str, "ORDER_LSB,");
-  if (rawattrib->align == XDEFLEFT) str = mputstr(str, "ORDER_MSB,");
-  else str = mputstr(str, "ORDER_LSB,");
+  if (get_type_refd_last()->typetype == T_OSTR) {
+    // the default alignment for octetstrings is 'left'
+    if (rawattrib->align == XDEFRIGHT) str = mputstr(str, "ORDER_LSB,");
+    else str = mputstr(str, "ORDER_MSB,");
+  }
+  else {
+    // the default alignment for all other types is 'right'
+    if (rawattrib->align == XDEFLEFT) str = mputstr(str, "ORDER_MSB,");
+    else str = mputstr(str, "ORDER_LSB,");
+  }
   if (rawattrib->bitorderinfield == XDEFMSB)
     str = mputstr(str, "ORDER_MSB,");
   else str = mputstr(str, "ORDER_LSB,");
diff --git a/core/RAW.cc b/core/RAW.cc
index 99482982f196484e212d05fcb3bd5d7da4fd9751..27938bd683f83fd964ab496c65339f4f62defb82 100644
--- a/core/RAW.cc
+++ b/core/RAW.cc
@@ -514,7 +514,7 @@ int min_of_ints(unsigned int num_of_int,...)
 const TTCN_RAWdescriptor_t INTEGER_raw_=               {8,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL};
 const TTCN_RAWdescriptor_t BOOLEAN_raw_=               {1,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL};
 const TTCN_RAWdescriptor_t BITSTRING_raw_=             {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL};
-const TTCN_RAWdescriptor_t OCTETSTRING_raw_=           {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL};
+const TTCN_RAWdescriptor_t OCTETSTRING_raw_=           {0,SG_NO,ORDER_LSB,ORDER_MSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL};
 const TTCN_RAWdescriptor_t HEXSTRING_raw_=             {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL};
 const TTCN_RAWdescriptor_t CHARSTRING_raw_=            {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL};
 const TTCN_RAWdescriptor_t FLOAT_raw_=                {64,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL};
diff --git a/function_test/RAW_EncDec/RAW_EncDec_TD.fast_script b/function_test/RAW_EncDec/RAW_EncDec_TD.fast_script
index c66ba5ee66d97783b388d079df631926c63058b1..db294f9a1b4d9a80b9c7f717df15b30099f77e19 100644
--- a/function_test/RAW_EncDec/RAW_EncDec_TD.fast_script
+++ b/function_test/RAW_EncDec/RAW_EncDec_TD.fast_script
@@ -375,9 +375,9 @@ testcase TC_FIELDLENGTH_4_and_BYTEORDER_first_for_octetstring() runs on TempComp
 
 testcase TC_FIELDLENGTH_4_for_octetstring_3_octets_long() runs on TempComp {
   const RAW_PDU_18 	i := '123456'O
-  const octetstring 	o := '00123456'O
+  const octetstring 	o := '12345600'O
 
-  if ((enc_RAW_PDU_18(i) == o)and(dec_RAW_PDU_18(o) == '00'O & i)) {setverdict(pass);}
+  if ((enc_RAW_PDU_18(i) == o)and(dec_RAW_PDU_18(o) == i & '00'O)) {setverdict(pass);}
   else {setverdict(fail,"enc_RAW_PDU_18(i)= ", enc_RAW_PDU_18(i), "; dec_RAW_PDU_18(o)= ", dec_RAW_PDU_18(o));}
 }
 
@@ -392,9 +392,9 @@ external function dec_RAW_PDU_19(in octetstring stream) return RAW_PDU_19 with {
 
 testcase TC_FIELDLENGTH_5_for_octetstring_2_octets_long() runs on TempComp {
   const RAW_PDU_19 	i := '1234'O
-  const octetstring 	o := '0000001234'O
+  const octetstring 	o := '1234000000'O
 
-  if ((enc_RAW_PDU_19(i) == o)and(dec_RAW_PDU_19(o) == '000000'O & i)) {setverdict(pass);}
+  if ((enc_RAW_PDU_19(i) == o)and(dec_RAW_PDU_19(o) == i & '000000'O)) {setverdict(pass);}
   else {setverdict(fail,"enc_RAW_PDU_19(i)= ", enc_RAW_PDU_19(i), "; dec_RAW_PDU_19(o)= ", dec_RAW_PDU_19(o));}
 }
 
@@ -418,9 +418,9 @@ testcase TC_FIELDLENGTH_4_and_BYTEORDER_last_for_octetstring() runs on TempComp
 
 testcase TC_FIELDLENGTH_4_and_BYTEORDER_last_for_octetstring_3_octets_long() runs on TempComp {
   const RAW_PDU_20 	i := '123456'O
-  const octetstring 	o := '56341200'O
+  const octetstring 	o := '00563412'O
 
-  if ((enc_RAW_PDU_20(i) == o)and(dec_RAW_PDU_20(o) == '00'O & i)) {setverdict(pass);}
+  if ((enc_RAW_PDU_20(i) == o)and(dec_RAW_PDU_20(o) == i & '00'O)) {setverdict(pass);}
   else {setverdict(fail,"enc_RAW_PDU_20(i)= ", enc_RAW_PDU_20(i), "; dec_RAW_PDU_20(o)= ", dec_RAW_PDU_20(o));}
 }
 
diff --git a/usrguide/referenceguide/4-ttcn3_language_extensions.adoc b/usrguide/referenceguide/4-ttcn3_language_extensions.adoc
index d924dcb2ad66d201c685654bc4fee52fa1b89e6f..76027e6801b7c13dca32492b48ff3dd3a8567a87 100644
--- a/usrguide/referenceguide/4-ttcn3_language_extensions.adoc
+++ b/usrguide/referenceguide/4-ttcn3_language_extensions.adoc
@@ -2514,7 +2514,7 @@ Attribute syntax: `ALIGN(<parameter>)`
 
 Parameters allowed: `left`, `right`
 
-Default value: `right`
+Default value: `left` for `octetstrings`, `right` for all other types
 
 Can be used with: stand-alone types or the field of a `record` or `set`.