Bounded Array Type?

Martin Uecker uecker@eecs.berkeley.edu
Thu Oct 23 05:12:00 GMT 2014



Sorry for bringing this up again, but this could work:

void foo(int x, int (*s)[x])
{
        (*s)[x] = 1;	// <- undefined behaviour
}

Such an access beyond the specified length means that either

1. the array is accessed out-of-bounds or
2. was accessed using an incompatible pointer 

and a compiler would be allowed to catch this.


Martin



More information about the Gcc mailing list