[cfe-dev] Why these problems below were not found by Clang Static Analyzer?
Jordan Rose
jordan_rose at apple.com
Fri Mar 14 11:35:26 PDT 2014
On Mar 14, 2014, at 11:31 , Nico Weber <thakis at chromium.org> wrote:
> On Fri, Mar 14, 2014 at 10:00 AM, Jordan Rose <jordan_rose at apple.com> wrote:
> The analyzer tries not to give results that are already covered by regular Clang warnings. This is sometimes problematic, since the Clang warnings may not be on by default. Nevertheless...
>
> On Mar 11, 2014, at 19:53 , apache <ehcapa at qq.com> wrote:
>
>> ----------------------------------------------------------------------
>> 1.case without break
>> e.g.
>> int test(const int n) {
>> int ret = 0;
>> switch(n) {
>> case 1:
>> ret = 1;
>> break;
>> case 2:
>> ret = 2; // this case branch has no 'break' statement.(coverity gived a warning here, but Clang didn't)
>> default:
>> break;
>> }
>> return ret;
>> }
>
> This is supposed to be -Wimplicit-fallthrough, but I don't see it working either! Richard, do you know what's going on here?
>
> In general, -Wimplicit-fallthrough does warn on this, which I mostly consider a bug: Falling through to a default: branch that contains nothing but a break is a) safe b) relatively common, so I think this shouldn't warn. (But it currently does, at least in blink.)
I tried adding a "ret = 3" too, and it still didn't warn. I'm not sure why.
Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140314/80b72d7e/attachment.html>
More information about the cfe-dev
mailing list