Several of the examples shown as valid C are not.
For example, this:
const int foo = 1;
int* bar = &foo;
*bar = 2;
is said to have undefined behavior, but in fact the initialization of `bar` is a constraint violation, requiring a diagnostic. (Some compilers will issue a non-fatal warning, which is allowed by the C standard but IMHO is unfortunate.)Another example: it says that this:
const size_t buffer_size = 5;
int buffer[buffer_size];
will not compile in C, but it's valid at block scope in C99, which introduced variable-length arrays. (C11 made them optional.)"In C, this would compile, albeit likely with warnings about implicit conversion:"
int main() {
auto x = "actually an int";
return x;
}
The "implicit int" rule was dropped in C99, and even before that the language did not define an implicit conversion from char* to int. Again, some compilers might support it with a warning, but it's a constraint violation.