patchgperf - Patches: patch #9561, Fix always-true subexpression in...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #9561: Fix always-true subexpression in step 4 of Search::find_positions()

Submitter:  Frank Wojcik <fwojcik>
Submitted:  Sat 10 Feb 2018 12:52:51 AM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  haible Open/Closed:  Closed

Sat 08 Sep 2018 01:57:49 PM UTC, comment #1: 

Thanks for the report. Yes, your guess was good. But the intent was also that i3 could be -1 (= LASTCHAR).

Bruno Haible <haible>
Group administrator
Sat 10 Feb 2018 12:52:51 AM UTC, original submission:  

Step 4 of Search::find_positions() contains an expression which is always true. Because the for loop makes i3 always be >=0:

                  for (int i3 = imax; i3 >= 0; i3--)

there is a subexpression in the if() test shortly thereafter that is always true:

                        if (try_duplicates_count < best_duplicates_count
                            || (try_duplicates_count == best_duplicates_count
                                && (i1 == -1 || i2 == -1 || i3 >= 0)))

This reduces to:

                        if (try_duplicates_count < best_duplicates_count
                            || (try_duplicates_count == best_duplicates_count
                                && 1)))

which reduces to:

                        if (try_duplicates_count <= best_duplicates_count)

which is probably not what is meant. The patch here is my educated guess at the intent.

Frank Wojcik <fwojcik>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #43224:  alwaystrue.diff added by fwojcik (634B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by haible (Posted a comment)
  • -email is unavailable- added by fwojcik (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-09-08 haible StatusNone Done
        Assigned toNone haible
        Open/ClosedOpen Closed
    2018-02-10 fwojcik Attached File- Added alwaystrue.diff, #43224

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code