News for hackers. Stuff that matters.
Re:Conflating pointers with arrays: C's biggest mistake? (2009) by bluecalm on Sunday July 22, 2018 @10:14AM (#17586848)
I object to reinterpreting bytes of one object as object of another type being C mindset. Yes, this is done sometimes if you really need it (compression being one example) but it's not really something you write everyday in C and doing it to calculate hash is just lazy.
Re:Conflating pointers with arrays: C's biggest mistake? (2009) by amluto on Sunday July 22, 2018 @11:41AM (#17587256)
Except that hashing a block of memory is likely to be much faster than hashing individual fields once there are more than a couple fields.

IMO the right solution would be a special annotation on a struct that says “I want the logical value of this struct to uniquely determine the bytes of the struct’s in-memory representation.”

Of course, adding such an attribute without nasty edge cases may be tricky.

Re:Conflating pointers with arrays: C's biggest mistake? (2009) by Tarean on Sunday July 22, 2018 @01:42PM (#17587860)
But this mostly matter for arrays and then an alternative optimization might be to store it as a structure of arrays. This doesn't need the padding and is more simd friendly.
Re:Conflating pointers with arrays: C's biggest mistake? (2009) by blub on Tuesday July 24, 2018 @05:32AM (#17599367)
The C mindset is one of always looking for optimisations and thinking at the bit & byte level. The above solution flows naturally...