C array size must be passed as a second argument
Yanpas opened this issue · comments
Yan Pashkovsky commented
From bubble sort code:
void bubblesort(int *v){
int i,j,aux;
int size = sizeof(v) / sizeof(v[0]); // Number of indexes in the V array.
sizeof(int*)
is always equal to size required for holding memory address (8bytes on 64bit arch). There should be second arg size_t v_len
.
Yan Pashkovsky commented
BTW (int v[])
, (int v[static 5])
, (int v[20])
etc. are all internally transformed to (int* v)
Matthias Endler commented
Hm... could you create a pull request for that @Yanpas? Would help me greatly in fixing this. Thank you very much for your report. 😃