C6000-CGT: Given multiple double input parameters, the 10th value is ignored.

Part Number: C6000-CGT

Tool/software:

Hello,

In the following example, the struct does not contain the expected values after initialization. The 10th element is not correctly initialized.

If I use float instead of double for e.g. var5, then the program prints as expected. If I replace var5 with two float var51 and var52 the program still works as expected.

Replacing the implementation in init_data.cpp with default initialization followed by per-element assignment does not fix the issue.

cl6x --help
TMS320C6x C/C++ Compiler v8.3.10
Tools Copyright (c) 1996-2018 Texas Instruments Incorporated


Compilation flags. Observed at all optimization levels.

-qq -mv6600 --relaxed_ansi --define=SOC_TDA3XX --keep_unneeded_statics --diag_wrap=off --display_error_number --diag_suppress=556 --diag_suppress=2458 --mem_model:data=far --wchar_t=16 --fp_reassoc=off --float_operations_allowed=all --ramfunc=off --emit_warnings_as_errors -O3 --opt_for_speed=4 -DNDEBUG --symdebug:none --c++14


Code
init_data.hpp
#ifndef INIT_DATA_HPP_
#define INIT_DATA_HPP_

struct Data
{
  double var1;
  double var2;
  double var3;
  double var4;
  double var5;
  double var6;
  double var7;
  double var8;
  double var9;
  double var10;
  double var11;
};

Data initData(double inVar1,
              double inVar2,
              double inVar3,
              double inVar4,
              double inVar5,
              double inVar6,
              double inVar7,
              double inVar8,
              double inVar9,
              double inVar10,
              double inVar11);

#endif  // INIT_DATA_HPP_


init_data.cpp
#include "init_data.hpp"

Data initData(double inVar1,
              double inVar2,
              double inVar3,
              double inVar4,
              double inVar5,
              double inVar6,
              double inVar7,
              double inVar8,
              double inVar9,
              double inVar10,
              double inVar11)
{
  return {inVar1, inVar2, inVar3, inVar4, inVar5, inVar6, inVar7, inVar8, inVar9, inVar10, inVar11};
}


init_data_app.cpp
#include "application_if/application_if.hpp"
#include "init_data.hpp"

#include <xdc/runtime/System.h>

namespace se
{
namespace application
{
void init()
{
  Data data = initData(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0);

  // Prints as expected.
  System_printf("Result 1: %f\n", data.var1);
  System_printf("Result 2: %f\n", data.var2);
  System_printf("Result 3: %f\n", data.var3);
  System_printf("Result 4: %f\n", data.var4);
  System_printf("Result 5: %f\n", data.var5);
  System_printf("Result 6: %f\n", data.var6);
  System_printf("Result 7: %f\n", data.var7);
  System_printf("Result 8: %f\n", data.var8);
  System_printf("Result 9: %f\n", data.var9);
  // Prints -0.000000 instead of 10.0.
  System_printf("Result 10: %f\n", data.var10);
  // Prints 11.0 as expected.
  System_printf("Result 11: %f\n", data.var11);
}
}  // namespace application
}  // namespace se


Output
Result 1: 1.0000
Result 2: 2.0000
Result 3: 3.0000
Result 4: 4.0000
Result 5: 5.0000
Result 6: 6.0000
Result 7: 7.0000
Result 8: 8.0000
Result 9: 9.0000
Result 10: -0.0000
Result 11: 11.0000