Various kinds of array argument deduction from temporaries fails. -Dave Release: 3.0.3 Environment: Cygwin How-To-Repeat: Compile the following: template <class T, unsigned N> void print1(T const (&x)[N]) { } template <class T, unsigned N, unsigned M> void print2(T const (&x)[N][M]) { } struct X { int x[2][4]; }; int main() { print1(X().x); print2(X().x); return 0; }
State-Changed-From-To: open->analyzed State-Changed-Why: confirmed, I don't think this is parser related.
Still happens on the mainline (20030526): pr5786.cc: In function `int main()': pr5786.cc:16: error: could not convert `X().X::x' to `const int (&)[2][4]' pr5786.cc:4: error: in passing argument 1 of `void print1(const T (&)[N]) [with T = int[4], unsigned int N = 2]' pr5786.cc:17: error: could not convert `X().X::x' to `const int (&)[2][4]' pr5786.cc:9: error: in passing argument 1 of `void print2(const T (&)[N][M]) [with T = int, unsigned int N = 2, unsigned int M = 4]'
*** Bug 11857 has been marked as a duplicate of this bug. ***
Most likely the same bug as PR 2892.
This could be fixed already...
(In reply to comment #5) > This could be fixed already... It is not: t.cc: In function ‘int main()’: t.cc:15: error: invalid initialization of non-const reference of type ‘const int (&)[2][4]’ from a temporary of type ‘int [2][4]’ t.cc:2: error: in passing argument 1 of ‘void print1(const T (&)[N]) [with T = int [4], unsigned int N = 2u]’ t.cc:16: error: invalid initialization of non-const reference of type ‘const int (&)[2][4]’ from a temporary of type ‘int [2][4]’ t.cc:7: error: in passing argument 1 of ‘void print2(const T (&)[N][M]) [with T = int, unsigned int N = 2u, unsigned int M = 4u]’
Still fails on GCC 4.4.0 20080413 (experimental).
This seems to be fixed for 4.5.
.