[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #47759] scanf should return min/max value on i
From: |
Mike Miller |
Subject: |
[Octave-bug-tracker] [bug #47759] scanf should return min/max value on integer range overflow |
Date: |
Fri, 22 Apr 2016 03:04:09 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0 |
URL:
<http://savannah.gnu.org/bugs/?47759>
Summary: scanf should return min/max value on integer range
overflow
Project: GNU Octave
Submitted by: mtmiller
Submitted on: Thu 21 Apr 2016 08:04:08 PM PDT
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Matlab Compatibility
Status: In Progress
Assigned to: mtmiller
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: Any
_______________________________________________________
Details:
According to tests in bug #47741, Matlab returns the minimum or maximum
integer value if the converted value overflows the storage limit of a 32-bit
integer (or 64-bit integer if %ld is used).
Octave currently stops conversion when it encounters a value that is out of
range.
Does Matlab also return an errmsg string when a value overflows? What does
Matlab do for the following:
format long
[x, count, errmsg] = sscanf('9999999999', '%d')
[x, count, errmsg] = sscanf('fffffffff', '%x')
The attached diff fixes the bug so overflow values are returned as the min/max
value possible and conversion continues with the next value, but does not set
errmsg. See also bug #46493 for why we can't currently set errmsg on success,
but we can at least mark it as something to fix later for compatibility.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Thu 21 Apr 2016 08:04:08 PM PDT Name: scanf-overflow.diff Size: 3kB
By: mtmiller
<http://savannah.gnu.org/bugs/download.php?file_id=36978>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?47759>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #47759] scanf should return min/max value on integer range overflow,
Mike Miller <=