|
![](/i/fill.gif) |
On 17/04/2012 11:16, Invisible wrote:
> Perhaps more alarming than anything I read in a book: Apparently in C++
> it is legal for a function to not have a return statement.
>
> As in, I declared my function as returning a value. I ran the program
> and printed out the result of the function. I got a segfault. I changed
> the code a bit, and ran it again. This time, it printed garbage, and
> /then/ it segfaulted.
>
> When I looked at my function, I found I'd written "it->second;" rather
> than "return it->second;". Not only is this apparently legal, it doesn't
> even generate a compile-time /warning/.
It's when I read things like that that I'm glad I found C# :-)
Post a reply to this message
|
![](/i/fill.gif) |