g++-4.7.0 emits an error for the following piece of code. ------------------------- BEGIN ----------------------------- #include <cstddef> #include <new> template <typename T = size_t> void f () { size_t coord [2][2]; new (&coord) size_t [2][2] { {0,0}, {0,0}, }; } int main () { f<>(); } ------------------------- END ----------------------------- The error message was error: parenthesized initializer in array new [-fpermissive] sorry, unimplemented: cannot initialize multi-dimensional array with initializer I observed the same behavior on 4.8.0. The problem only occurs inside function template according to my test. If I made f an ordinary function, the code was accepted. Clang 3.2 and Visual Studio 2012 all accept the code. These facts led me to assume this is a bug in g++. Below is my g++ version. Reading specs from /home/meng/gcc/4.7.0/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/specs COLLECT_GCC=/home/meng/gcc/4.7.0/bin/c++ COLLECT_LTO_WRAPPER=/home/meng/gcc/4.7.0/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ./configure --prefix=/home/meng/gcc/4.7.0 --enable-languages=c,c++ -disable-multilib Thread model: posix gcc version 4.7.0 (GCC)
I see a sorry message thus the issue seems known.
(In reply to comment #1) > I see a sorry message thus the issue seems known. I agree. What confused me was that the feature is not unimplemented, it worked well for ordinary functions. I wonder what makes function templates a special exception in this case.
Fixed for 4.8.1/4.9.