Adding true; / false; is clearly valid C++ code. It compiles and runs just fine.
Similarly, this is the same for statements like int;, void;, {}(no ()), 1+1;, 1 == 1;, or even just 1; ... why? (I'm using Visual C++)
Why not? The language specification clearly states that expression statement in C++ looks as follows
<expression>;
This is exactly what you have in your examples like true; or 1 == 1; or 1;.
The {} is just an empty compound statement.
Meanwhile, int; is ill-formed. If the compiler accepts it quietly, it must be some sort of compiler-specific quirk/bug/extension.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With