PING #2 [PATCH] 69517 - [5/6 regression] SEGV on a VLA with excess initializer elements

Martin Sebor msebor@gmail.com
Mon Mar 21 22:10:00 GMT 2016


I'm looking for a review of the patch below.  I noticed a piece
of commented out code in there.  Please assume that I will remove
it before the final commit.

As a heads up, I'm traveling this Thursday through Sunday and
won't have access to email to answer questions or address
comments until next Monday.

Martin

On 03/14/2016 03:26 PM, Martin Sebor wrote:
> Ping:
>    https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00441.html
>
> On 03/06/2016 06:38 PM, Martin Sebor wrote:
>> GCC 4.9 had added support for C++ VLAs as specified in WG21
>> document N3639 expected to be included in C++ 14.  However,
>> WG21 ultimately decided not to include N3639 in C++ 14 and
>> the G++ support was partially removed in 5.1.  Unfortunately,
>> the removal rendered some safe albeit erroneous G++ 4.9 code
>> undefined.  This patch restores the well-defined behavior of
>> such code by having it throw an exception in response to
>> the erroneous conditions.
>>
>> While testing the patch I found a number of other problems in
>> the G++ support for VLAs, including PR c++/70019 - VLA size
>> overflow not detected, which was never implemented (not even
>> in 4.9).  Since this is closely related to the regression
>> discussed in 69517 the patch also provides that support.
>>
>> There are a few additional points to note about the patch:
>>
>> 1) It restores the std::bad_array_length exception from N3639,
>>     even though the class isn't specified by the C++ standard.
>>     At first I thought that introducing a different (private)
>>     type would be more appropriate, but in the end couldn't come
>>     up with a good argument for not keeping the same type.  Using
>>     the same type also allows programs that rely on the exception
>>     and that were built with GCC 4.9 to be ported to GCC 6 without
>>     change.
>>
>> 2) It hardwires a rather arbitrarily restrictive limit of 64 KB
>>     on the size of the biggest C++ VLA.  (This could stand to be
>>     improved and made more intelligent, and perhaps integrated
>>     with stack  checking via -fstack-limit, after the GCC 6
>>     release.)
>>
>> 3) By throwing an exception for erroneous VLAs the patch largely
>>     defeats the VLA Sanitizer.  The sanitizer is still useful in
>>     C++ 98 mode where the N3639 VLA runtime checking is disabled,
>>     and when exceptions are disabled via -fno-exceptions.
>>     Disabling  the VLA checking in C++ 98 mode doesn't seem like
>>     a useful feature, but I didn't feel like reverting what was
>>     a deliberate decision.
>>
>> Martin
>



More information about the Gcc-patches mailing list