Question

I encountered something interesting and annoying while programming a matrix class: internal compiler error. I was willing to invoke a sister constructor in the class called Matrix4<T>::Matrix4(Matrix4<T>&&). This is the piece of code that generates this error:

template<typename T>
Matrix4(Matrix4&& matrix_) = default;

template<typename T>
Matrix4<T>::Matrix4(T (&&matrix_)[4][4]):
    Matrix4({
        .data = {
            {matrix_[0][0], matrix_[0][1], matrix_[0][2], matrix_[0][3]},
            {matrix_[1][0], matrix_[1][1], matrix_[1][2], matrix_[1][3]},
            {matrix_[2][0], matrix_[2][1], matrix_[2][2], matrix_[2][3]},
            {matrix_[3][0], matrix_[3][1], matrix_[3][2], matrix_[3][3]}
        }
    })
{

}

And, this is the internal compiler error (compiler is GCC and IDE is Code::Blocks):

internal compiler error: in process_init_constructor_array, at cp/typeck2.c:1080

Supposedly the compiler cannot successfully parse my code. I'm pretty sure the syntax is alright, though. What can I do in this situation?

Was it helpful?

Solution

Try compiling it with a different compiler. It's possible that there is a very subtle error with your code, and another compiler might be able to tell you more. I recommend trying out Clang, as it has widely been touted for having better error messages, though the most recent versions of GCC are seeking to change this notion.

If it fails on both compilers without a real error message in sight, then you have some of the finest test-code for this bug at your disposal and submitting a bug report about it would be much appreciated by the compiler community.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top