Everything in C is undefined behavior

28 points by gerikson


davmac

This is ridiculous. It's saying that literally that:

int foo(const int* p) {
   return *p;
}

... "has" UB because you can pass it a pointer that's not properly aligned, and that's UB.

That's ignoring that you already have UB before the function is called, in that case, and also trivial things like that you can pass a null pointer to this function and it would be UB in that case too, but nobody would normally claim that this means the function "has" UB.

Yeah C has a lot of undefined behaviour, but this post is just over-exaggerating waffle.