[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #65342] replace atoi with stoi
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #65342] replace atoi with stoi |
Date: |
Sat, 2 Mar 2024 23:19:19 -0500 (EST) |
Follow-up Comment #3, bug #65342 (group octave):
The patch works fine when values are normal and within range. However, if the
conversion cannot be completed then C++ throws an exception. The conversions
need to be protected with try/catch blocks in order to prevent an immediate
halt of the program. Here is an example session with the patch applied:
dbtype ls xyz
terminate called after throwing an instance of 'std::invalid_argument'
what(): stoi
fatal: caught signal Aborted -- stopping myself...
Abort (core dumped)
This is very different from the C function atoi which returns a 0 if the
conversion cannot be made. This value is checked in the existing code to
produce a reasonable error message and then a return to the Octave prompt.
dbtype ls xyz
error: dbtype: start and end lines must be >= 1
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?65342>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #65342] replace atoi with stoi, anonymous, 2024/03/02
- Message not available
- Message not available
- Message not available
- [Octave-bug-tracker] [bug #65342] replace atoi with stoi,
Rik <=
- Message not available
- Message not available
- Message not available
- Message not available