This is probably a good example of why (in my opinion) this is a bad idea for typedef array types.
Unlike other contexts, in function declarations, an array type parameter is always set to an equivalent pointer type. When an array is passed to a function, it always decays to a pointer to the first element.
These two fragments are equivalent:
typedef unsigned char Str[257]; Str src = "blah"; Str dst; memcpy( &dst, &src, sizeof(Str) );
unsigned char src[257] = "blah"; unsigned char dst[257]; memcpy(&dst, &src, sizeof(unsigned char[257]));
In this latter case, &dst and &src both of type unsigned char (*)[257] , but the value of these pointers matches the value of pointers to the first element of each array, which makes dst and src decays if passed directly to memcpy like this.
memcpy(dst, src, sizeof(unsigned char[257]));
memcpy accepts void* arguments, so the types of source pointers do not matter, only their values.
Due to the rule for parameter declarations (an array type of any or undefined size is set to an equivalent pointer type), these declarations for fn equivalent:
typedef unsigned char Str[257]; void fn( Str dst, Str src );
void fn( unsigned char dst[257], unsigned char src[257] );
void fn( unsigned char dst[], unsigned char src[] );
void fn( unsigned char* dst, unsigned char* src );
Looking at this code, it is more obvious that the values ββpassed to memcpy , in this case, are pointers to passed pointers, and not pointers to actual unsigned char arrays.
With typedef, the error is not so obvious, but still present.