[cfe-dev] Variable length arrays are not permitted in C++
theraven at sucs.org
Tue Feb 16 09:21:51 PST 2010
On 16 Feb 2010, at 17:08, Eli Friedman wrote:
> Anything that works in C probably works in C++ as well; it gets
> complicated when we try to deal with constructs like VLAs with
> non-trivial destructors, using a VLA with new, attempting to use a
> variably modified type as a template argument, attempting to use a
> variably modified type inside a local class, etc. The idea is that if
> we're going to support VLAs inside of C++, we should make sure they
> work correctly in every situation, not just in trivial cases.
There is already a bug tracking this:
There's a patch attached to it for handling VLAs with just POD types. Handling them with other types sounds like it would be quite complex. I'm not sure if this even works reliably with GCC either - I've heard some complaints that it doesn't, but they might have been from older versions of GCC.
As this is a GCC extension, presumably our priority is compatibility with existing code, rather than implementing every possible case, so only supporting POD types might be Good Enough™, as long as we emit a helpful error if someone tries to use VLAs with non-POD types.
-- Sent from my Cray X1
More information about the cfe-dev