public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "meng at g dot clemson.edu" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-56772-4@http.gcc.gnu.org/bugzilla/> (raw)


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 <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)


             reply	other threads:[~2013-03-28 20:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-28 20:59 meng at g dot clemson.edu [this message]
2013-03-28 23:43 ` [Bug c++/56772] placement new operator does not work inside function template for array types paolo.carlini at oracle dot com
2013-03-29  0:45 ` meng at g dot clemson.edu
2013-04-01 20:32 ` jason at gcc dot gnu.org
2013-04-01 21:22 ` jason at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-56772-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).