[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #58617] cell2struct silently truncates char ma
From: |
Kai Torben Ohlhus |
Subject: |
[Octave-bug-tracker] [bug #58617] cell2struct silently truncates char matrices |
Date: |
Thu, 18 Jun 2020 22:31:57 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 |
URL:
<https://savannah.gnu.org/bugs/?58617>
Summary: cell2struct silently truncates char matrices
Project: GNU Octave
Submitted by: siko1056
Submitted on: Fri 19 Jun 2020 04:31:55 AM CEST
Category: Interpreter
Severity: 2 - Minor
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Release: dev
Discussion Lock: Any
Operating System: BSD
_______________________________________________________
Details:
A subtle truncation happens when calling
containers.Map(['foo';'bar';'baz'], [1,2])
https://lists.gnu.org/archive/html/octave-maintainers/2020-06/msg00088.html
The cause is that cell2struct allows the following:
Octave 6.0.1:
>> cell2struct({[1,2]}, {['foo','bar','baz']})
ans =
scalar structure containing the fields:
foobarbaz =
1 2
>> cell2struct({[1,2]}, {['foo';'bar';'baz']})
ans =
scalar structure containing the fields:
foo =
1 2
while Matlab R2020b does not:
>> cell2struct({[1,2]}, {['foo','bar','baz']})
ans =
struct with fields:
foobarbaz: [1 2]
>> cell2struct({[1,2]}, {['foo';'bar';'baz']})
Error using cell2struct
Field name must be a character vector or string scalar.
I agree to Matlab's behavior in this case, because my valuable key is
truncated, without a warning.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?58617>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #58617] cell2struct silently truncates char matrices,
Kai Torben Ohlhus <=