bugGNU nano - Bugs: bug #53333, undefined pointer comparison

 
 

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

bug #53333: undefined pointer comparison

Submitter:  None
Submitted:  Mon 12 Mar 2018 09:04:16 PM UTC
   
 
Severity:  2 - Minor Status:  Fixed
Assigned to:  bens Open/Closed:  Closed

Sun 18 Mar 2018 01:04:45 PM UTC, comment #4: 

Fixed in git, commit 95989e7d.

Thanks for reporting.

Benno Schulenberg <bens>
Group administrator
Thu 15 Mar 2018 05:06:42 PM UTC, comment #3: 

s/place/placed/

Benno Schulenberg <bens>
Group administrator
Thu 15 Mar 2018 05:05:21 PM UTC, comment #2: 

One example in my current binary where the order differs from the source code: do_toggle_void() is not place right after do_toggle() but far before it.

Another example: to_first_file() and to_last_file() are place far before do_browser() instead of far after it.

So yes, this needs fixing: an ugly comparison with all the relevant movement functions.  :|

Benno Schulenberg <bens>
Group administrator
Thu 15 Mar 2018 04:54:11 PM UTC, comment #1: 

You are probably right in that there is no guarantee about the order of the functions in the binary.  A year or two ago I wanted to see how the binary code changed for some tiny change in the source code.  It was hard to compare the two binaries because one of the functions moved to a wholly different place, changing all of the addresses.

But when I disassemble nano's binary on my system, the functions in move.c appear to be perfectly ordered.  So for now it will work.

Benno Schulenberg <bens>
Group administrator
Mon 12 Mar 2018 09:04:16 PM UTC, original submission:  

Building nano 2.9.4 with clang 5 shows these warnings:

nano.c:1773:26: warning: ordered comparison of function pointers ('void ()(void)' and 'void ()(void)')
                                                                        (shortcut->func >= to_first_line &&
                                                                         ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~
nano.c:1774:25: warning: ordered comparison of function pointers ('void ()(void)' and 'void ()(void)')
                                                                        shortcut->func <= do_right))) {
                                                                        ~~~~~~~~~~~~~~ ^  ~~~~~~~~

As best as I can guess, this comparison tries to check whether shortcut->func points to a function contained in move.c.  I don't think this check is well-defined in C.  I don't expect that there is any guarantee in what order functions are emitted in a compilation unit.

Anonymous

 

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

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bens (Posted a comment)
  •  

    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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-03-30 bens Severity3 - Normal 2 - Minor
        Open/ClosedOpen Closed
    2018-03-18 bens StatusNone Fixed
    2018-03-15 bens Assigned toNone bens
        SummaryUndefined pointer comparison undefined pointer comparison

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code