On Wed, 16 Jan 2013, Eitan Adler wrote:
On 16 January 2013 13:11, Xin Li <delp...@delphij.net> wrote:
Yes I did. Using exit(3) tells clang that this is the final exit and
thus eliminates the warning.
It sounds like a bug (or arguably a feature) that clang does not
recognize return in main()s...
It is not a bug: see
Of course it is a bug.
http://clang-developers.42468.n3.nabble.com/Static-analyzer-possible-memory-leak-false-positive-td4026706.html
Not much signal there.
C99 requires main() to be handled specially in hosted environments.
(In freestanding environments(), neither main() nor malloc() is special.
Now the compiler could warn about main(), but it cannot know what
malloc() does so it cannot warn about not freeing memory on return
from main().) It requires that, if the return type of main() is
compatible with int (and thus not void), then a return from the
_initial_ call to main() is equivalent to calling exit() with an arg
equal to the return value (and that if main() doesn't explicitly return
or exit, but falls through to the closing brace, then this is equivalent
to 'return (0);'.
It seems to be permitted to call malloc() recursively (otherwise C99
w. The warning is useful if main() is called recursively. But few
programs call main() recursively. pwait(1) obviously doesn't. The
the bug is quality of implementation one. The static analyzer is too
stupid to see that main() isn't called recursively.
Bruce
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"