[SERVER-58874] Coverity analysis defect 120344: Operands don't affect result Created: 27/Jul/21  Updated: 27/Oct/23  Resolved: 25/Aug/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Mindaugas Malinauskas
Resolution: Works as Designed Votes: 0
Labels: coverity
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
is caused by SERVER-57321 $mod match expression incorrectly han... Closed
Operating System: ALL
Sprint: QE 2021-08-09, QE 2021-08-23, QE 2021-09-06
Participants:

 Description   

Operands don't affect result

The expression's value does not depend on the operands; often, this represents an inadvertent logic error. An operation with non-constant operands that computes a result with constant value
/src/mongo/bson/bsonelement.h:1090: CONSTANT_EXPRESSION_RESULT 120344 "val > 9223372036854775807LL /* std::numeric_limits<long long>::max() */" is always false regardless of the values of its operands. This occurs as the logical first operand of "||".



 Comments   
Comment by Mindaugas Malinauskas [ 25/Aug/21 ]

It is a false positive. The tool does not "see" that if T== long long, the marked line is not reachable since the function returns above that line. Marked as False Positive in Coverity.

Comment by Kyle Suarez [ 28/Jul/21 ]

mindaugas.malinauskas, it looks like the tryCoerce() function was most recently changed by your work in SERVER-57321 so I'm sending this one your way.

Generated at Thu Feb 08 05:45:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.