This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++] Reject variably modified types in operator new
- From: Alexander Monakov <amonakov at ispras dot ru>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 1 Jun 2012 17:03:05 +0400 (MSK)
- Subject: Re: [C++] Reject variably modified types in operator new
- References: <4FC4F2AE.2090106@redhat.com>
As someone who wrote code that does such allocations, I'm surprised that this
is a GNU extension, and is rejected even by the C++11 standard. How is one
supposed to perform allocations of two-dimensional arrays when inner dimension
is given as function argument?
I'm relatively inexperienced, but let me disagree about the assessment of this
feature as "obscure". I would expect that some existing programs that
perform, say, CFD calculations on two- or three-dimensional regular grids,
or, better yet, do image processing, would allocate grid data in exactly that
manner, and would be broken by this change:
void foo(int gridSizeH, int gridSizeV)
{
typedef double gridRow[gridSizeH];
gridRow *grid = new gridRow[gridSizeV];
...
}
Therefore I suggest a deprecation period with -fpermissive.
Thanks.
Alexander