Out of range access on structs leads to bad data
John W. Eaton
jwe at bevo.che.wisc.edu
Tue Aug 12 12:23:25 CDT 2008
On 12-Aug-2008, Kim Hansen wrote:
| Hi,
|
| I get this error on octave 3.0.1 (the Debian unstable package). I
| don't have a build of the development Octave to test on.
|
| I expected "error: invalid vector index = 2" from line 2.
|
| ====================
| octave:1> a.b=1
| a =
| {
| b = 1
| }
|
| octave:2> c=a(2);
| octave:3> c
| c =
| {
| b =
|
| error: octave_base_value::print (): wrong type argument `<unknown type>'
|
| }
|
| octave:3> d=c.b;
| error: value on right hand side of assignment is undefined
| error: evaluating assignment expression near line 3, column 2
| octave:3>
Try the following patch. It will catch the case you show above, but
will still fail for something like
x.a.a = 1
x(2).a
I see no simple way to completely fix this problem without also
breaking the following valid code:
x(1).a.a = 1
x(2).a.a = 2
The code in Octave that handles indexed assignment is what really
needs to be fixed so that we can allow resizing when an index
expression is on the left side of an assignment and properly detect
the index-out-of-range error when it is not. But that is a large
and relatively risky change and so I don't see it happening before the
3.2 release. At least it is just a missed error, not a case where we
are failing to properly interpret valid code.
jwe
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: diffs
Url: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080812/41b8e037/attachment.ksh
More information about the Bug-octave
mailing list