back

by uecker·3y ago·view on hn ↗
While the size of the VLA is not (usually) known at compile time, it is part of its type and known at run-time (it is a dependent type). And if you use a pointer to the VLA (and not a decayed pointer), you can recover the size or benefit from run-time bounds checking.

  int n;
  char buf[n];
  char (*p)[n] = &buf;   // non decayed pointer to array
  sizeof(*p);