On Wednesday, January 16, 2013 2:15:00 pm 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
> http://clang-developers.42468.n3.nabble.com/Static-analyzer-possible-memory-
leak-false-positive-td4026706.html

No, it is clearly a bug.  It is a waste of time and adds obfuscation (and 
runtime overhead) to go free a bunch of stuff just before a return() from 
main().  The vast, vast majority of time main() is used as main(), so it 
should clearly by the default behavior to treat a return() from main() the 
same as exit() and possibly have an option to toggle that setting.  As to the 
last post in that thread, the same problem exists if you malloc something 
early in main() and later call exit(), so that has no bearing on whether or 
not a return() from main() should be treated as an exit().

-- 
John Baldwin
_______________________________________________
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"

Reply via email to