Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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.

C6000-CGT: Bug with const char* member of compile time constant

Part Number: C6000-CGT

Hello

I believe I have found a bug in the TI C6000 CGT (still present in 8.3.10).

The following code produces assembler error E0300:

struct X
{
        const char *name;

        constexpr X(const char *n) : name(n) {}

        static constexpr X x1() { return X("x1"); }
        static constexpr X x2() { return X("x2"); }
};

void f()
{
    X::x1();
    X::x2();
}

(sorry about the formatting, insert code doesn't seem to work correctly)

The problem disappears

  • if I remove one of the calls to x1() or x2() from f(), or
  • if I remove the constexpr-ness from x1() and x2(), or
  • if I change the type of "name" to e.g. int (and initialize it accordingly)

No other compiler that I tried seems to take issue with the code.

Kind regards

Markus

EDIT: naming the strings first (i.e. creating a constexpr const char name1[] = "x1"; etc) and using pointers to those names also compiles.