[webkit-dev] Can we disable "control reaches end of non-void function" warning on Qt?

Darin Adler darin at apple.com
Fri Sep 13 10:13:16 PDT 2013


On Sep 12, 2013, at 2:07 PM, Ryosuke Niwa <rniwa at webkit.org> wrote:

> http://trac.webkit.org/changeset/155643 broke Qt build with an error saying:
> 
> Source/JavaScriptCore/dfg/DFGGPRInfo.h:169:5: error: control reaches end of non-void function [-Werror=return-type]
> cc1plus: all warnings being treated as errors
> 
> because of the following code:
> 
> GPRReg gpr(WhichValueWord which) const
> {
>     switch (which) {
>     case TagWord:
>         return tagGPR();
>     case PayloadWord:
>         return payloadGPR();
>     }
> }
> 
> But the code works just fine as is because WhichValueWord only takes two values (TagWord and PayloadWord) and they're all handled in the switch statement.
> 
> Can we disable this warning so that we don't have to add a bogus code like the one I had to add in http://trac.webkit.org/changeset/155649/trunk/Source/JavaScriptCore/dfg/DFGGPRInfo.h ?

I don’t think disabling the warning is the right thing to do.

Since there’s no runtime guarantee that the enum will have a valid value, I think there needs to be a return statement outside the switch, even if we have ASSERT_NOT_REACHED before it.

-- Darin


More information about the webkit-dev mailing list