[PATCH] D19971: [scan-build] fix warnings emitted on LLVM TargetRecip code base

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon May 9 15:00:24 PDT 2016


spatel added inline comments.

================
Comment at: lib/Target/TargetRecip.cpp:74
@@ -73,3 +73,3 @@
   size_t RefPos;
-  uint8_t RefSteps;
+  uint8_t RefSteps = 0;
   StringRef RefStepString;
----------------
apelete wrote:
> spatel wrote:
> > apelete wrote:
> > > spatel wrote:
> > > > dblaikie wrote:
> > > > > Does msan ever diagnose this as use-of-uninitialized? Or is this only used in the codepaths where it is initialized?
> > > > The intent was that RefSteps could only be used when RefStepString is valid and therefore not empty (see 'report_fatal_error' just above this). Could this be a false positive from scan-build?
> > > This one looks like a false positive indeed: scan-build seems unable to see that RefSteps is initialized in parseRefinementStep() below.
> > > Should I remove the initializations here and ignore the warnings ?
> > Yes, initializing to '0' could mask an actual problem. You could add asserts of the RefSteps value [0-9] just after the calls to parseRefinementStep() if that would make scan-build happier.
> Assert on RefSteps <= 9 does not suppress the "assigned value is garbage or undefined" warnings on lines 105, 155 and 161 below in this case.
> Ignoring the warnings in this file sound like the sanest thing to do.
Right - if we can't avoid the false positives, let's leave it alone.


http://reviews.llvm.org/D19971





More information about the llvm-commits mailing list