From: A Curious Developer on 27 Jul 2010 06:48 > One of them, C4715, is "not all control paths return a value". Sure > enough, the function in question has a return type of int, and there > are various embedded returns but no final return at the end, a control > path that it can get to. > > So my question is, "why is this not a fatal compilation error?". It might have been done that way so that compilers don't need to do code analysis to determine which paths might or might not be taken and so the language wouldn't be complicated by rules covering which kinds of analysis need to be done. Also, some paths that throw exceptions might have no reasonable return values. (That is just a guess ... I don't necessarily agree it justifies the results.) I think gcc has an option to give related warnings - -Wreturn-type, perhaps. -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
|
Pages: 1 Prev: Boost.Any doesn't respect type conversion Next: on a quest for C++ hamcrest matchers library |