Here's the problem. After adding to helpers.c a linear search that will return true if the value is found (per the pset3 spec), I "make all" in the terminal to update helpers.c before testing it, but get the following error:

helpers.c:34:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]


^ 1 error generated. make: *** [find] Error 1

I've searched the threads here and have seen many questions (many labeled duplicate) that address this problem. But after reading their answers, I still don't understand a) why this error is occurring and b) how to fix it.

1 Answer 1


Compilers are dumb. They won't do exhaustive logic analysis of a function, but they will check to see if they think there's a path through the code that doesn't end with a return statement, assuming the function has a return type. That's almost certainly what's happened in your case.

Here's an indepth explanation, but perhaps overly thorough. Maybe it will help. How to solve "control may reach end of non void function" error

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

  • Thank you. The explanation you link to mentioned a concept that seems pretty important: control flow. I watched all the videos leading up to this pset: the lectures, sections, and shorts. None of them even mention control flow. But maybe I'm missing something.
    – MEK
    Mar 26, 2016 at 3:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .