From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5870 invoked by alias); 28 Mar 2013 20:59:24 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 5854 invoked by uid 48); 28 Mar 2013 20:59:17 -0000 From: "meng at g dot clemson.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/56772] New: placement new operator does not work inside function template. Date: Thu, 28 Mar 2013 20:59:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: meng at g dot clemson.edu X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 X-SW-Source: 2013-03/txt/msg02135.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56772 Bug #: 56772 Summary: placement new operator does not work inside function template. Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: meng@g.clemson.edu g++-4.7.0 emits an error for the following piece of code. ------------------------- BEGIN ----------------------------- #include #include template 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)