This my seem like a ridiculous question but today I wrote a member function in C++ that is supposed to return and int but doesn't always. I even wrote a really simple function that doesn't return a value...
int derp()
{
if (11 == 22) return 0;
}
Is this a recent change? is my compiler broken? lol
EDIT: this does compile btw
In a non-void function all control paths must return. The key issue here is that the compiler is not required to diagnose it. Note that compile and is correct are not necessarily the same. All correct code compiles, but not all code that compiles is correct.
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