Program: 6497
Project: 6497
Buggy source:
/** 
 * Generate code for EXI serialization with C++. The code is created individually for each bean object.
 * @param elementMetadata Queue with metadata of XML elements
 * @param exiGrammar Object with schema-informed EXI grammar
 * @throws Exception Error during code generation
 */
private void generateSerializeCode(final Queue<ElementMetadata> elementMetadata,Grammar exiGrammar) throws Exception {
  CppVar typeObject=CppVar.factory.create(Cpp.NONE,this.beanClassName + "String_Node_Str","String_Node_Str");
  CppVar streamObject=CppVar.factory.create(Cpp.NONE,"String_Node_Str","String_Node_Str");
  CppVar functionPointer=CppVar.factory.create(Cpp.NONE,"String_Node_Str","String_Node_Str");
  CppFun serialize=CppFun.factory.create("String_Node_Str","String_Node_Str",typeObject,streamObject,functionPointer);
  String serializerCode="String_Node_Str";
  while (!elementMetadata.isEmpty()) {
    ElementMetadata element=elementMetadata.poll();
    serializerCode+=CppEXIConverter.createNiceCommentDelimiter(String.format("String_Node_Str",element.getElementName())) + "String_Node_Str";
switch (element.getType()) {
case ElementMetadata.XML_ATOMIC_VALUE:
      serializerCode+=String.format("String_Node_Str",element.getElementEXIType(),element.getElementName());
    break;
case ElementMetadata.XML_LOCAL_ELEMENT:
  serializerCode+=String.format("String_Node_Str",element.getElementEXIType(),element.getParentName(),element.getElementName());
break;
case ElementMetadata.XML_ARRAY:
serializerCode+=String.format("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",element.getParentName(),element.getElementName(),0,element.getElementEXIType(),element.getParentName(),element.getElementName());
break;
case ElementMetadata.XML_LIST:
serializerCode+=String.format("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",0,element.getElementName(),element.getElementEXIType(),element.getElementName());
break;
default :
throw new FabricEXIException("String_Node_Str");
}
}
String methodBody=String.format("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",serializerCode);
serialize.appendCode(methodBody);
serialize.setComment(new CCommentImpl(String.format("String_Node_Str",this.beanClassName)));
this.serializerClass.add(Cpp.PUBLIC,serialize);
}

Fixed version (ground truth):
/** 
 * Generate code for EXI serialization with C++. The code is created individually for each bean object.
 * @param elementMetadata Queue with metadata of XML elements
 * @param exiGrammar Object with schema-informed EXI grammar
 * @throws Exception Error during code generation
 */
private void generateSerializeCode(final Queue<ElementMetadata> elementMetadata,Grammar exiGrammar) throws Exception {
  CppVar typeObject=CppVar.factory.create(Cpp.NONE,this.beanClassName + "String_Node_Str","String_Node_Str");
  CppVar streamObject=CppVar.factory.create(Cpp.NONE,"String_Node_Str","String_Node_Str");
  CppVar functionPointer=CppVar.factory.create(Cpp.NONE,"String_Node_Str","String_Node_Str");
  CppFun serialize=CppFun.factory.create("String_Node_Str","String_Node_Str",typeObject,streamObject,functionPointer);
  String serializerCode="String_Node_Str";
  while (!elementMetadata.isEmpty()) {
    ElementMetadata element=elementMetadata.poll();
    serializerCode+=CppEXIConverter.createNiceCommentDelimiter(String.format("String_Node_Str",element.getElementName())) + "String_Node_Str";
switch (element.getType()) {
case ElementMetadata.XML_ATOMIC_VALUE:
      serializerCode+=String.format("String_Node_Str",element.getElementEXIType(),this.firstLetterCapital(element.getElementName()));
    break;
case ElementMetadata.XML_LOCAL_ELEMENT:
  serializerCode+=String.format("String_Node_Str",element.getElementEXIType(),this.firstLetterCapital(element.getParentName()),this.firstLetterCapital(element.getElementName()));
break;
case ElementMetadata.XML_ARRAY:
serializerCode+=String.format("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",this.firstLetterCapital(element.getParentName()),this.firstLetterCapital(element.getElementName()),0,element.getElementEXIType(),this.firstLetterCapital(element.getParentName()),this.firstLetterCapital(element.getElementName()));
break;
case ElementMetadata.XML_LIST:
serializerCode+=String.format("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",0,this.firstLetterCapital(element.getElementName()),element.getElementEXIType(),this.firstLetterCapital(element.getElementName()));
break;
default :
throw new FabricEXIException("String_Node_Str");
}
}
String methodBody=String.format("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",serializerCode);
serialize.appendCode(methodBody);
serialize.setComment(new CCommentImpl(String.format("String_Node_Str",this.beanClassName)));
this.serializerClass.add(Cpp.PUBLIC,serialize);
}