public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56772] New: placement new operator does not work inside function template.
@ 2013-03-28 20:59 meng at g dot clemson.edu
  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
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: meng at g dot clemson.edu @ 2013-03-28 20:59 UTC (permalink / raw)
  To: gcc-bugs


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)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/56772] placement new operator does not work inside function template for array types.
  2013-03-28 20:59 [Bug c++/56772] New: placement new operator does not work inside function template meng at g dot clemson.edu
@ 2013-03-28 23:43 ` paolo.carlini at oracle dot com
  2013-03-29  0:45 ` meng at g dot clemson.edu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-03-28 23:43 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|meng at g dot clemson.edu   |

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-03-28 23:43:23 UTC ---
I see a sorry message thus the issue seems known.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/56772] placement new operator does not work inside function template for array types.
  2013-03-28 20:59 [Bug c++/56772] New: placement new operator does not work inside function template meng at g dot clemson.edu
  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
  3 siblings, 0 replies; 5+ messages in thread
From: meng at g dot clemson.edu @ 2013-03-29  0:45 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from meng at g dot clemson.edu 2013-03-29 00:45:23 UTC ---
(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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/56772] placement new operator does not work inside function template for array types.
  2013-03-28 20:59 [Bug c++/56772] New: placement new operator does not work inside function template meng at g dot clemson.edu
  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
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2013-04-01 20:32 UTC (permalink / raw)
  To: gcc-bugs


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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2013-04-01
                 CC|                            |jason at gcc dot gnu.org
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/56772] placement new operator does not work inside function template for array types.
  2013-03-28 20:59 [Bug c++/56772] New: placement new operator does not work inside function template meng at g dot clemson.edu
                   ` (2 preceding siblings ...)
  2013-04-01 20:32 ` jason at gcc dot gnu.org
@ 2013-04-01 21:22 ` jason at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2013-04-01 21:22 UTC (permalink / raw)
  To: gcc-bugs


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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.8.1

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2013-04-01 21:22:40 UTC ---
Fixed for 4.8.1/4.9.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-04-01 21:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-28 20:59 [Bug c++/56772] New: placement new operator does not work inside function template meng at g dot clemson.edu
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

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