http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57769

--- Comment #2 from Henri <korpela.henri.mikael at gmail dot com> ---
(In reply to Paolo Carlini from comment #1)
> Please add here a minimized self-contained reproducer. Also, you are not
> saying which version of GCC you are using.

My GCC version is currently 4.7. I use Code::Blocks as my IDE.

Interesting that my attempt to reproduce the internal compiler error fails in
the self-contained code below (with compiler errors)...

class C{
public:

    C(C&&) = default;

    explicit C(int (&array)[2][2]) : C({
        ._m_array = {
            {array[0][0], array[0][1]},
            {array[1][0], array[1][1]}
        }
    })
    {

    }

private:
    int _m_array[2][2];
};

int main(void){
    int array[2][2] = {
        {1, 2},
        {3, 4}
    };
    C c(array);
    return 0;
}

||In constructor 'C::C(int (&)[2][2])':|
|42|error: no matching function for call to 'C::C(<brace-enclosed initializer
list>)'|
|42|note: candidates are:|
|37|note: C::C(int (&)[2][2])|
|37|note:   no known conversion for argument 1 from '<brace-enclosed
initializer list>' to 'int (&)[2][2]'|
|35|note: constexpr C::C(C&&)|
|35|note:   no known conversion for argument 1 from '<brace-enclosed
initializer list>' to 'C&&'|
||=== Build finished: 1 errors, 0 warnings (0 minutes, 0 seconds) ===|

...and somehow succeeds here:

class C{
public:

    C(C&&) = default;

    explicit C(int (&&array)[2][2]) : C({
        ._m_array = {
            {array[0][0], array[0][1]},
            {array[1][0], array[1][1]}
        }
    })
    {

    }

private:
    int _m_array[2][2];
};

int main(void){
    C c({{
        {1, 2},
        {3, 4}
    }});
    return 0;
}

||In constructor 'C::C(int (&&)[2][2])':|
|42|internal compiler error: in process_init_constructor_array, at
cp/typeck2.c:1080|
||=== Build finished: 1 errors, 0 warnings (0 minutes, 0 seconds) ===|

This leads me to believe that the compiler fails to parse rvalue references to
multidimensional arrays in a scenario like this.

Reply via email to