Possible Duplicate:
Why can you return from a non-void function without returning a value without producing a compiler error?
Why does gcc 4.6.1 compile the following function without a return statement?
uint32_t& siof_solution() {
static uint32_t example = (uint32_t) 7; // Doesn't really matter
// return example;
}
It returns 1. I seen’t it.
C++ functions aren’t required to return a value even if they say they do. If they don’t, the result is undefined behavior. In your case, through Sheer Dumb Luck the code seems t be working, but it’s not portable and not safe. This could crash, return a garbage pointer, cause a debug error, etc.
I think the reason for this decision is mostly backwards-compatibility with C, though I’m not sure.
Hope this helps!