Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 1.5 KB

bounds.mkd

File metadata and controls

38 lines (28 loc) · 1.5 KB

Bounds Checking

C has a bounded pointer type: A variably-modified type, i.e. a type to a VLA.

int N = 10;
char (*p)[N] = malloc(sizeof *p);
if (!p)
 abort();
 
(*p)[N] = 1; // run-time bounds check possible

f(int n, char buf[static n]);
f(N, *p); // bounds checking possible