bugGNU Octave - Bugs: bug #61132, Colon operator fails for int64 and...


bug #61132: Colon operator fails for int64 and uint64

Submitted by:  None
Submitted on:  Thu 09 Sep 2021 01:19:46 AM UTC  
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  In Progress Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  dev
Operating System:  GNU/Linux

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Tue 14 Sep 2021 06:35:43 PM UTC, comment #5: 

Oops again.  When I recently added integer ranges, I made the mistake of assuming that we could check for type compatibility (integers of the same type possibly mixed with doubles) and then if we have an integer range (integer operands possibly mixed with integer values stored as doubles), we could convert all the operands to the single integer type.  I completely forgot about the possibility of something like

lo = uint8 (10);
hi = uint8 (20);

I'll take another look at that since I think it should be valid.

Reopening as "in progress".

John W. Eaton <jwe>
Project Administrator
Mon 13 Sep 2021 10:26:09 PM UTC, comment #4: 

Hello jwe. A follow-up problem for all unsigned integer types, not just uint64.

hi = intmax("uint64");  # OK
lo = hi-99;             # OK
up = lo:hi;             # OK
down = hi:-1:lo;        # error: colon operator increment invalid (not an integer or out of range for given integer type)
down = fliplr(up);      # current workaround to the error
charup = 'a':'z';       # for comparison. this is OK.
chardown = 'z':-1:'a';  # for comparison. this is OK too!

Is this a conscious limit that one cannot construct descending ranges for unsigned integer types with the colon operator or is it a bug?

Thu 09 Sep 2021 02:22:33 PM UTC, comment #3: 

I added a test and pushed the following changeset


Closing as fixed.

John W. Eaton <jwe>
Project Administrator
Thu 09 Sep 2021 01:51:56 PM UTC, comment #2: 

I confirm that the patch works as intended. Thank you to jwe for the very fast fix!

Thu 09 Sep 2021 03:45:30 AM UTC, comment #1: 

Oops.  I'm attaching a possible patch.

(file #51880)

John W. Eaton <jwe>
Project Administrator
Thu 09 Sep 2021 01:19:46 AM UTC, original submission:  

This problem happens for int64 and uint64 types on Octave 7:

octave:16> lo = uint64(10) ^ 17
lo = 100000000000000000
octave:17> hi = lo + 1e3
hi = 100000000000001000
octave:18> class(lo)
ans = uint64
octave:19> class(hi)
ans = uint64
octave:20> lo < intmax ("uint64")
ans = 1
octave:21> hi < intmax ("uint64")
ans = 1
octave:22> rng = (lo:hi)
error: colon operator upper bound invalid (not an integer or out of range for given integer type)

The values lo and hi are within the legal range for int64 and uint64 but the colon operator fails when trying to create what should be a valid range.



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

Attach Files:

Attached Files
file #51880:  range-error-diffs.txt added by jwe (2KiB - text/plain)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by jwe (Updated the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-09-14 jwe StatusFixed => In Progress
        Open/ClosedClosed => Open
    2021-09-09 jwe StatusPatch Submitted => Fixed
        Open/ClosedOpen => Closed
    2021-09-09 jwe Attached File- => Added range-error-diffs.txt, #51880
        StatusNone => Patch Submitted

    Back to the top

    Powered by Savane 3.6