[ros-dev] [ros-diffs] [pschweitzer] 50612: [NTOSKRNL/PPC] Fix the fix, spott

Pierre Schweitzer pierre.schweitzer at reactos.org
Mon Feb 7 08:47:21 UTC 2011


Hi,
this is a bit tricky, but it is the way it works.
In case you still have doubts, enjoy that C program. You will never reach the memset:

#include <assert.h>
#include <string.h>

void test_sizeof(unsigned long test[4], char c) {
    assert(sizeof(test) == (4 * sizeof(unsigned long)));
    memset(test, c, sizeof(test));
}
void main() {
    unsigned long tab[4];
    test_sizeof(tab, '?');
}

Regards,
P. Schweitzer

> Hey,
> 
> Yes, array arguments are just simple pointers in C, so sizeof will
> return the size of a pointer to the base type.
> Exercise for the reader: Predict what happens when you try passing an
> int[4] into an int[8] argument.
> 
> WBR,
> 
> Roel Messiant
> 




More information about the Ros-dev mailing list