Who Owns the Memory? Part 3: How Big Is your Type?

32 points by lukefleed


fanf

Great stuff once again:-)

Regarding repr(C):

each struct begins with a discriminant of the platform’s C int size: … tag: u64 …

Is the tag is supposed to be an int-sized discriminant? I expected i32 or c_int.

Is MyVariantB supposed to be the same layout as B(f32, u64)?

int compare_ints(const void *a, const void *b) {
    return *(const int*)a - *(const int*)b;
}

This has an overflow bug :-)