<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62836>62836</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Enabled -Wvla-extension by default in C++ compilation modes
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            enhancement,
            c++,
            clang:diagnostics
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          AaronBallman
      </td>
    </tr>
</table>

<pre>
    Good or bad, Clang supports VLAs in C++ code. However, this comes as quite the surprise to users (https://ddanilov.me/default-non-standard-features/ among plenty of others) and there are more idiomatic alternatives that users should consider using in C++. I think we should enable `-Wvla-extension` by default in C++ so that users are made aware of this extension, especially given the security implications around stack overflows with VLAs that can be mitigated by heap allocations through C++ containers.

One challenge to this is that our existing warnings around VLAs and extensions are awkward and should be addressed: https://godbolt.org/z/eEnMsr4zG (we claim we're making a VLA as an extension and then saying nevermind, we decided to make it a constant array, also as an extension).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VM1y4zYMfhr6grFHpmInPujgZNfbzrTTW3uGSFhiQxEqAVnrffoOZWeTZqYXSRxi8P3gg1AkdImoMbtns_uywkl7zs0RM6dnjHHAtGrZX5tvzB44Q4ve2Bd4iZg6kGkcOavAn78dBUKCF2OfjX0Gx5428AvPdKFc6rUPAo4HEkCBf6agBNoTyJTHHIRAGSahLGDsU686iqmPxp6MPXmPKUS-bAYqJzrjFHWdOK1FMXnMfn0m1CmTGHsCHDh1MEZKegU-A2tPWYw9ACZfMDMBZoKBM0HwgQfU4ACjUk6o4UIC2qPe6UjPU_TgOEnwlGGSkLoPUjfwaxGXXmGmt2JK2EYCs6_Wf10irum7UpLAyewraK9w1_DRMOGPoAs_9AQ4l08-3_x772NfgGQkFzDGK3ThQulmJ7kpB71CGMYYHGrgVNrxlDyIonsFvlA-R54F5qD9bXILtMMELcEQNHSo5AvTnnAEjJHfWmmfeer6D4NOiiFRlo2pvpjqeHv-kQhcjzFS6pbZLvzDHYmnDPQ9iBYrZ8wppO4ny4VQGdVPtTc_cH6dMfvl6u5zS4DeZxIhb-oj_Dc3HfuWo244d8aefhh7oq_pd8kPP76VkM0ELmIYYCZjHxfDXwsfLAxKSDG9U3jLTgLBa6lKJdhDSMsyzASeXPDki9QBXwmCAi6hUUwKmDNeSyVG4c-9jT1sVr6p_aE-4Iqa7f7pYf94eLTVqm-8r57czpGvnWu9RV9XOyS_bbeOnhy1q9DYytbVzm63D_XOVhvXbuvHrfVnXx_QbyvzUNGAIW5ivAzFjFUQmajZ26d6v4rYUpRl-62l1GNyNFBSY62xL8Zadxv0-7ksvqmPPmCXWDQ4KXe7L6vcFIR1O3ViHqoYROUdU4NGar4ui-Hh01r8z044HsYQl-DBwJ5kNeXYfBpy0H5qN44HY08F7f5aj5n_JqfGnha55dewKP43AAD__z3tr-c">