[cfe-dev] [analyzer] RFC, garbage value => out of bounds

Joachim Durchholz via cfe-dev cfe-dev at lists.llvm.org
Mon Mar 14 05:49:15 PDT 2016


Am 14.03.2016 um 13:21 schrieb Daniel Marjamäki via cfe-dev:
> Also I classify this as a FP. In the real code it is known that nr is
> not greater than 2. Clang is just guessing for no reason that it can
> be bigger than 2. So to silence this, as far as I know we'll have to
> add a redundant assertion or something.

If the function can be called from unknown locations, clang has no way 
of knowing this.
I suspect that making the code a private member function could make 
clang confident that it knows all calling locations.

The assert might really help. It would also document to future 
maintainers that the nr parameter is constrained to a range, so it would 
be very much non-redundant.


More information about the cfe-dev mailing list