Opened 6 years ago

Last modified 5 years ago

#12360 new Bugs

dead code detected by coverity in mersenne_twister

Reported by: James E. King, III <jim.king@…> Owned by: No-Maintainer
Milestone: To Be Determined Component: random
Version: Boost 1.54.0 Severity: Optimization
Keywords: Cc:

Description

This is from boost 1.54 - it would be wise to re-test this on the development trunk to ensure it is still there before resolving it. This would be considered a trivial performance optimization by removing a branch.

    {
   assignment: Assigning: j = 623UL.
   const: At condition j < 623UL, the value of j must be equal to 623.
   dead_error_condition: The condition j < 623UL cannot be true.
430        for(std::size_t j = n-1-unroll_extra2; j < n-1; j++) {
   CID 10152 (#1 of 1): Logically dead code (DEADCODE)dead_error_begin: Execution cannot reach this statement: y = (this->x[j] & 0x8000000....
431            UIntType y = (x[j] & upper_mask) | (x[j+1] & lower_mask);
432            x[j] = x[j-(n-m)] ^ (y >> 1) ^ ((x[j+1]&1) * a);
433        }
434    }

Change History (3)

comment:1 by Marshall Clow, 5 years ago

I don't think there's enough information here to make a change. Can you tell me what the caller, etc was doing?

comment:2 by Steven Watanabe, 5 years ago

This definitely is a spurious warning. The code in question may or may not be dead depending on the template parameters.

comment:3 by jim.king@…, 5 years ago

If you want to close it out that's fine. I just checked and found that boost is not covered in Coverity Scan. I think it would be really useful, especially given each boost project is separate in github, to have a Coverity Scan project covering each boost project. It is a useful tool that finds problems, and you can never have enough quality controls on software.

Note: See TracTickets for help on using tickets.