[cfe-dev] Fwd: Opinion on Analyzer false positive

Jordan Rose jordan_rose at apple.com
Wed Oct 24 17:14:23 PDT 2012


CCing cfe-dev because somehow I forgot to the first time around.


Begin forwarded message:

> From: Jordan Rose <jordan_rose at apple.com>
> Subject: Re: [cfe-dev] Opinion on Analyzer false positive
> Date: October 24, 2012 at 13:55:53 PDT
> To: Erik Cederstrand <erik at cederstrand.dk>
> 
> 
> On Oct 24, 2012, at 13:31 , Erik Cederstrand <erik at cederstrand.dk> wrote:
> 
>> Hi guys,
>> 
>> The Static Analyzer spits out this report on some ZFS code http://scan.freebsd.your.org/freebsd-head/WORLD/2012-10-24-amd64/report-uH6BjZ.html#EndPath
>> 
>> The code is OK in my opinion because the default return value for getopt(3) is '?': http://www.unix.com/man-page/posix/3posix/getopt/
>> 
>> I could change the '?' case to 'default:' but this is a pretty common pattern (plus, it's not our own code). Is it possible to create a special case for getopt() in the Analyzer? It would require splitting the input string to getopt() to restrict the possible return values of getopt().
> 
> This is definitely theoretically possible - a postCall check on getopt to assert that certain return values are impossible, based on the input string. Patches welcome. ;-)
> 
> Meanwhile, you (or the author) can put assert(false) or __builtin_unreachable in a default case to satisfy the analyzer.
> 
> Jordan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121024/f85b3e5d/attachment.html>


More information about the cfe-dev mailing list