This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/C6000-CGT: Compiler 8.3.6 gives invalid diagnostic 342-D: value copied to temporary, reference to temporary used

Part Number: C6000-CGT

Tool/software: TI C/C++ Compiler

Given the code example:

#include <utility>

int main()
{
  auto retPair = std::make_pair(-1, false);
  return retPair.first;
}

compiled as follows:

$CGT_PATH/bin/cl6x -I$CGT_PATH/include example.cpp --issue_remarks -pdv -pden)

The compiler produces the following output:

"example.cpp", line 5: remark #342-D: value copied to temporary, reference to
          temporary used
    auto retPair = std::make_pair(-1, false);
                                  ^

"example.cpp", line 5: remark #342-D: value copied to temporary, reference to
          temporary used
    auto retPair = std::make_pair(-1, false);
                                      ^

Since this is the typical use-case of std::make_pair (and std::make_pair's signature is changed to accept rvalue references in C++14 which are created specifically to allow references to temporaries), I would not expect such a diagnostic.

Due to this bug, I have to suppress the 342 diagnostic. This is undesirable, since a correct 342 diagnostic would (in general) indicate a pretty serious and hard to debug problem.

  • Thank you for reporting this problem, and providing a concise test case.  I can reproduce the same behavior. I filed the entry EXT_EP-9743 to have this investigated.  You are welcome to follow it with that link.

    Due to this bug, I have to suppress the 342 diagnostic. This is undesirable, since a correct 342 diagnostic would (in general) indicate a pretty serious and hard to debug problem.

    Understood.  There are ways to limit how much code is compiled with this diagnostic suppressed.  Please search the C6000 compiler manual for the sub-chapter titled Understanding Diagnostic Messages.  Consider applying the build option --diag_suppress=342 to only some of the source files, and not all of them.  Also consider using #pragma diag_suppress 342, a few lines of source code that get the diagnostic, then #pragma diag_default 342.  I don't know if will be practical in all cases, but it is worth considering.

    Thanks and regards,

    -George