[cfe-dev] [staticAnalyzer] abort() not recognized as 'noreturn' function

Eli Friedman eli.friedman at gmail.com
Sun Aug 9 11:52:19 PDT 2009


On Sun, Aug 9, 2009 at 11:01 AM, Дмитрий Дьяченко<dimhen at gmail.com> wrote:
> Hello,
>
> static checker rev.78534, Fedora 10/x86, release build  for a code
> below produce incorrect diagnostique message.
>
> scan-build gcc -c abort.c
> abort.c:9:1: warning: control may reach end of non-void function [-Wreturn-type]
> }
> ^
> ANALYZE: abort.c foo
> 1 diagnostic generated.
>
> #include <stdlib.h>
>
> int foo(int x)
> {
>    if(x != 0)
>        abort();
>    if(x == 0)
>        return 0;
> }
>
> Looks as checker does not recognize 'noreturn' for abort() function.
> For 'exit()' checker emits similar message.
>
> Is this a known problem? Or i miss something trivial?

That message isn't emitted by the analyzer component, but rather by
clang's semantic analysis, which isn't clever enough to deal with
opposite conditions.

If the warning triggers often enough that it's annoying, please file a bug.

-Eli




More information about the cfe-dev mailing list