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.

compound literals fail to implicitly instantiate template types



The following C++ code that uses a compound literal (GCC language extension) fails to compile:

template< int n >
struct Foo { };

void init_foo( Foo<0> *p ) {
    *p = (Foo<0>){ };   // error: a compound literal of type "Foo<0>" is not allowed
}

The issue appears to be that the compiler is neglecting to implicitly instantiate the template type, since the error disappears if the type Foo<0> has already been (explicitly or implicitly) instantiated prior to using the compound literal, e.g. this compiles just fine:

template< int n >
struct Foo { };

Foo<0> blah;  // implicitly instantiates Foo<0>

void init_foo( Foo<0> *p ) {
    *p = (Foo<0>){ };
}

I've tested the latest clpru (v2.3.3) as well as the cl7x I had lying around (v3.1.0.LTS), presumably it applies to all TI compilers that share the same C/C++ frontend code.