C++ - What can be done with internal compiler errors?

别说谁变了你拦得住时间么 提交于 2019-12-20 06:05:28

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/17391748/c-what-can-be-done-with-internal-compiler-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!