Just in case anyone is curious, the error was having `sizeof(key - r)` instead of `sizeof(key) - r`
Rookie mistake!
Rookie mistake!
a = malloc(sizeof(*a));
It's also useful for various hacks (stuff like compile-time assert macros), since it doesn't evaluate the expression, only its type.But it perhaps it could be useful for those following the NetBSD style. :-)
Without getting into typing, a simple
warning: arithmetic inside sizeof
would catch this. I don't think it would catch much noise, I don't see any useful uses of pointer arithmetic immediately inside a sizeof. It's a bit specific though, are there more functions that would benefit as well?