C++ Logo


Advanced search

Subject: Re: dynamic size of a fixed array - compiles well on gcc, why?
From: Ville Voutilainen (ville.voutilainen_at_[hidden])
Date: 2020-06-15 02:44:22

On Mon, 15 Jun 2020 at 10:24, Bernhard Manfred Gruber via
Std-Discussion <std-discussion_at_[hidden]> wrote:
> Hi Hollowone PL,
> what you discovered is actually a feature. It's called VLAs (Variable Length Arrays).
> Strictly speaking, VLAs are not a C++ feature but were introduced in the C99 standard and then made optional in C11.
> Your compiler is supporting them, because it supports C as well to C++.

It does come as a surprise to innocent users that g++ is not a C++
compiler out of the box. Run it with -std=c++20 -pedantic-errors
and it becomes one. It will default to a -std=gnu++, not a -std=c++,
and even with the latter, it still doesn't bother warning about or
rejecting extensions, so you need to ask it to do so.

STD-DISCUSSION list run by herb.sutter at gmail.com

Older Archives on Google Groups