vendredi 5 juin 2015

Using curly braces to value-initialize temporary as initializer to static data member causes error

This very simple code code gives an error in GCC 6.0:

template<class T>
struct S {
    // error: cannot convert 'T' to 'const int' in initialization
    static const int b = T{};
};

int main() {
}

Strangely, if I use regular braces instead (T()) then the code compiles. Is this a bug? The code compiles fine in clang.

Aucun commentaire:

Enregistrer un commentaire