something that worries me is padding in hashmap key types. a while back i experienced a nasty surprise when i discovered clang to optimize copy operations around unused bytes in structs, causing padding to contain uninitialized memory and thus messing up hashes.

#devlog #C

@lritter It's not just Clang. Padding bytes are a 'no-go-area' for C and C++ compilers.

One area where I've seen padding bytes being lost was calling a function which takes a struct by value (and I seem to remember not just for small structs where the struct content is passed in registers), or even just assigning one struct to another without using memcpy (but tbh I wouldn't even trust memset or memcpy, since these are essentially builtins today).

@lritter PS: I think this is the relevant part from the C standard (via https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf):