[cfe-dev] [RFC] Approach for C++1y N3639 (runtime-sized arrays with automatic storage duration)
Ronan Keryell
Ronan.Keryell at silkan.com
Thu May 9 15:09:54 PDT 2013
>>>>> On Thu, 9 May 2013 14:48:11 -0700, Richard Smith <richard at metafoo.co.uk> said:
Ronan> How to deal with C function definitions such as:
Ronan> void foo(int n, int m, float array[n][m]) {
Ronan> }
Ronan> where do you put the test for n and m?
Richard> I don't think a test is necessary here, because this
Richard> declaration doesn't allocate storage. Instead, any relevant
Richard> test should have been performed when the argument passed as
Richard> 'array' was created. I definitely see value in verifying
Richard> that the 'array' argument can be used to access at least n
Richard> * m floats, but I think that belongs in a separate check
Richard> (maybe ASan could be taught to verify this).
I was thinking to this kind of creative programming using the example
above:
{
float a[100][10];
foo(-5000, -365, a);
}
But you are right, it is to be tested by some more or less static
analyzers instead, since it is not related to the allocation itself.
--
Ronan KERYELL |\/ Phone: +1 650 386 6482
SILKAN Wild Systems |/)
4962 El Camino Real #201 K Ronan.Keryell at silkan.com
Los Altos, CA 94022 |\ skype:keryell
USA | \ http://silkan.com
More information about the cfe-dev
mailing list