Menu

knownConditionTrueFalse False Positive (very easy to reproduce)

2021-10-11
2021-10-11
  • Steve Albright

    Steve Albright - 2021-10-11

    style: knownConditionTrueFalse - Condition '(index+1)%2==0' is always false

    void knownConditionTrueFalseFalsePositiveExample()
    {
       for(unsigned int index = 0; index < 100; ++index)
       {
          if((index + 1) % 2 == 0)
          {
             // should get here half the time, not NEVER
          }
          else
          {
             // should get here half the time, not ALWAYS
          }
       }
    }
    
     
  • CHR

    CHR - 2021-10-11

    I can't reproduce this with either 2.6 or head.

     
  • Steve Albright

    Steve Albright - 2021-10-11

    I forgot to mention I am on 2.5, I didn't know 2.6 was available.

     
    👍
    1

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.