[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an erro
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an error for N=0 |
Date: |
Sat, 22 Feb 2020 00:00:33 -0500 (EST) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko |
Follow-up Comment #4, bug #57879 (project octave):
The use of N < 0 most likely indicates a situation the programmer did not
anticipate and I believe Octave should produce an error for this case,
regardless of what Matlab does. In general, Octave validates its inputs more
carefully than Matlab in order to prevent garbage in / garbage out
calculations.
I feel the same way about N = 0, but there is a better argument to be made
there because zero length, i.e., empty strings are real whereas strings with
negative length do not exist.
Note that the C library function uses size_t for N which is an unsigned data
type. That suggests requiring N to be in the range [0, MAX_INT] during input
validation. Otherwise, -1 will be mapped to MAX_INT-1 which will not do the
right thing at all.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?57879>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an error for N=0, Utkarsh Dhandhania, 2020/02/21
- [Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an error for N=0, Nicholas Jankowski, 2020/02/21
- [Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an error for N=0, Nicholas Jankowski, 2020/02/21
- [Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an error for N=0, Mike Miller, 2020/02/21
- [Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an error for N=0, Utkarsh Dhandhania, 2020/02/21
- [Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an error for N=0, Nicholas Jankowski, 2020/02/21
- [Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an error for N=0,
Rik <=
- Message not available
- Message not available
- [Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an error for N=0, Utkarsh Dhandhania, 2020/02/22
- [Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an error for N=0, Samarth Agarwal, 2020/02/27
- [Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an error for N=0, Samarth Agarwal, 2020/02/27
- [Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an error for N=0, Nicholas Jankowski, 2020/02/27
- [Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an error for N=0, Rik, 2020/02/27
- [Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an error for N=0, Samarth Agarwal, 2020/02/27
- [Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an error for N=0, Nicholas Jankowski, 2020/02/27
- [Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an error for N=0, Rik, 2020/02/27
- [Octave-bug-tracker] [bug #57879] strncmp(str_a, str_b, N) gives an error for N=0, Utkarsh Dhandhania, 2020/02/27