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

    <tr>
        <th>Summary</th>
        <td>
            [UBSAN] Odd behavior with vla typedef
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    Consider following code

```c
#define my_cool_assert(cond)        \
    typedef char __static_assert_type[(cond) ? 0 : -1]

void foo(void)
{
    ({ my_cool_assert(({ my_cool_assert(1); 1; })); });
}

```

There should be no code emitted, since all computations happen at compile time. However clang (tho and gcc) emits call to `__ubsan_handle_vla_bound_not_positive`.

If I am reading following correctly, in such case nested expression should not be evaluated, since there is no "instantiation" of this type.

```
 // C11 6.7.6.2p5:
          //   If the size is an expression that is not an integer constant
          //   expression [...] each time it is evaluated it shall have a value
          //   greater than zero.
```


Godbolt: https://godbolt.org/z/YqPKrrjY4
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx0VFGP4yYQ_jX4ZbQW4MROHvyQbJR2Vamt1PbhniwMY8OVgAvY2-yvr7Bzve3tNbISBjIf3_fNeESMZnSILdmfyf5SiDlpH9op_hlGMRa9V_f22btoFAYYvLX-1bgRpFdI6Ck_Nd0emQNeKRyMQ7jdO-m97USMGBLhB-mdIvwIjw_ZPxN6yqt0n1DhAFKLAF0Xk0hGPvK6fJiZfc0n1RUokOoET4zsLxuJxRsFg_eEH_KS8GPeb86PKwg_kOb8kdP_7bMMUJ2B5S_SXHK47TyC6rziX76xYAt_1xgQovazVdAjOL_aBXgzKaEi_BmicRJBWAvS36Y5S_YughbThA5EWreNRUjmhiX86F9xwQDSCjdmNUl7EE7BKGX2JCNHkBkveSA17bq5j8J1WjhlsVus6Ho_O9U5n7rJR5PMgqSm5cb4ZYAXEDcIKFSu7vs6h4Ay2XtmbRzEWWqQIiI4jAkV4N9TwBiNd18UO5-yalyEncV_9KbVGBOzI4Rz42ISLplVPOEc_ABJm7h2RPnRWiD8SvgVnhmDumzKuuTTnlSnR5EffbX9B-AlgyFE87ZeKdx7qkmLtBFJ-cS4hGP212-Uvo_4Lp_sz2VZkv0FUEi9VgnMiviv7BxHnUuixYIgIB_g95HHgCJhyLQcvGHw5ceuIvT0g1e9tyn3vk5piln7CjFuB6UPI-HXN8Kvn_769acQPn_aFaqt1LE6igJb1jR101BOaaFb3FXI-YANk0zSWvYN3x9koySVgvd4KEzLKa_pjjPGWL2j5UCZQDn0yJqm7xUjO4o3YWxp7XLLdxcmxhlbdqzYsSqs6NHGda5wvnYu4TyPmNDmhKd-HiPZUWtiil8hkkl2HUZ_nH87_Zwd_kXlt0iLxfgAryZpWKz4MjWKOdj2GzNM0nNfSn8j_JpxHz9PU_CfUSbCryvPSPj1QXVp-T8BAAD__0Dej_A">