Is there any C warning for memcmp(a, b, sizeof(type)) if either *a and *b are not of the type (or if struct doesn't start with type, etc)?
-
-
Good suggestions (I like the a==b case)! I'm concerned == has less strict checks than =. Not sure about ?: type checks.
-
They're all constraint violations so a compiler that doesn't warn is non-conforming.
-
I can confirm they work, cool! a == b || memcmp(a, b, sizeof(*a)) even seems like normal reasonable code, the warning is surprising though.
-
int a = 0; int b = 0; if (&a == &b || memcmp(&a, &b, sizeof(a)) { // Looks a bit odd though but will optimize well.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.