'GetValidGuess': not all control paths return a value

Severity Code Description Project File Line Suppression State
Warning C4715

‘GetValidGuess’: not all control paths return a value

BullCowGame f:\users\justin jahn\documents\visual studio 2017\projects\justinsection_02\bullcowgame\main.cpp 110

Also when entering less than the preset of 7 characters I get message that says ‘Debug Error!.. abort() has been called…’

don’t know what to do. possibly unique to VS2017. Code looks perfect.

It would be nice to see a snippet with the code.

My guess is your missing a “return” statement somewhere in your code. I’m running VS 2017 and didn’t encounter this issue.


I have seen the error on my end too. It was because my GetValidGuess function finished without doing a “return”.
You might want to check to see if there is anyway your function code could end without doing the “return” statement.

hope this helps.


Hi All,

This is fine. The warning is something you can ignore in this case, Ben actually says that this is fine in the Lecture “Using Switch Statements” (Sec2 Lec44).
What the compiler doesn’t like is that it is possible for the code to continue indefinitely, hence “not all control paths return a value” - as in, there is a “route” the User can take which doesn’t return a value and so let you exit the application.
Ordinarily you would be right to dislike that warning but given the simplicity of the application and the fact that it has no real world impact (e.g. if your bank’s money transfer screen had such an issue and let you submit infinite payments without an end) beyond a mildly annoyed User we can safely set our concerns to one side this time.

**EDIT: In a later lecture this does get fixed. It was OK to ignore for the very short term but it is best practice to not ignore any warnings, hence why the fix was covered later.


Privacy & Terms