Uninitialized array
smoutault opened this issue · comments
smoutault commented
It seems to me that there is an error with uninitialized arrays. Elements should not be initialized to 0 as is currently the case seems to me.
For example :
#include <stdio.h>
int main() {
float tab[2];
for(int i = 0; i < 2; i++){
printf("%f, ", tab[i]);
}
return 0;
}
gives 0.00000, 0.00000 instead of NaN, NaN.
The C99 standard says that "if an object that has an automatic storage duration is not explicitly initialized, its value is undetermined." I think it's the same in C++ (or not ?).
Felix Hao commented
Yes defaulting to zero can hide potential errors. I will use NaN instead. Thanks.